MCPcopy Index your code
hub / github.com/plotly/dash / sideUpdate

Function sideUpdate

dash/dash-renderer/src/actions/callbacks.ts:396–461  ·  view source on GitHub ↗

* Update a component props with `running`/`progress`/`set_props` calls. * * @param outputs Props to update. * @param cb The originating callback info. * @returns

(outputs: SideUpdateOutput, cb: ICallbackPayload)

Source from the content-addressed store, hash-verified

394 * @returns
395 */
396function sideUpdate(outputs: SideUpdateOutput, cb: ICallbackPayload) {
397 return function (dispatch: any, getState: any) {
398 toPairs(outputs)
399 .reduce((acc, [id, value], i) => {
400 let componentId = id,
401 propName,
402 replacedIds = [];
403
404 if (id.startsWith('{')) {
405 [componentId, propName] = parsePMCId(id);
406 replacedIds = replacePMC(componentId, cb, i, getState);
407 } else if (id.includes('.')) {
408 [componentId, propName] = id.split('.');
409 }
410
411 const props = propName ? {[propName]: value} : value;
412
413 if (replacedIds.length === 0) {
414 acc.push([componentId, props]);
415 } else if (replacedIds.length === 1) {
416 acc.push([replacedIds[0], props]);
417 } else {
418 replacedIds.forEach((rep: any) => {
419 acc.push([rep, props]);
420 });
421 }
422
423 return acc;
424 }, [] as any[])
425 .forEach(([id, idProps]) => {
426 const state = getState();
427
428 const componentPath = getPath(state.paths, id);
429 let oldComponent = {props: {}};
430 if (componentPath) {
431 oldComponent = getComponentLayout(componentPath, state);
432 }
433
434 const oldProps = oldComponent?.props || {};
435
436 const patchedProps = parsePatchProps(idProps, oldProps);
437
438 dispatch(updateComponent(id, patchedProps, cb));
439
440 if (!componentPath) {
441 // Component doesn't exist, doesn't matter just allow the
442 // callback to continue.
443 return;
444 }
445
446 dispatch(
447 setPaths(
448 computePaths(
449 {
450 ...oldComponent,
451 props: {...oldComponent.props, ...patchedProps}
452 },
453 [...componentPath],

Callers 5

handleServersideFunction · 0.85
completeJobFunction · 0.85
handleOutputFunction · 0.85
handleWebsocketCallbackFunction · 0.85
__executeFunction · 0.85

Calls 10

parsePMCIdFunction · 0.90
replacePMCFunction · 0.90
getPathFunction · 0.90
getComponentLayoutFunction · 0.90
parsePatchPropsFunction · 0.90
computePathsFunction · 0.90
getStateFunction · 0.85
updateComponentFunction · 0.85
reduceMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…