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

Function recordUiEdit

dash/dash-renderer/src/persistence.js:312–358  ·  view source on GitHub ↗
(layout, newProps, dispatch)

Source from the content-addressed store, hash-verified

310};
311
312export function recordUiEdit(layout, newProps, dispatch) {
313 const {
314 canPersist,
315 id,
316 props,
317 element,
318 persistence,
319 persisted_props,
320 persistence_type
321 } = getProps(layout);
322
323 // if the "persistence" property is changed as a callback output,
324 // skip the persistence storage overwriting.
325 const isPersistenceMismatch =
326 newProps?.persistence !== undefined &&
327 newProps.persistence !== persistence;
328
329 if (!canPersist || !persistence || isPersistenceMismatch) {
330 return;
331 }
332
333 forEach(persistedProp => {
334 const [propName, propPart] = persistedProp.split('.');
335 if (newProps[propName] !== undefined) {
336 const storage = getStore(persistence_type, dispatch);
337 const {extract} = getTransform(element, propName, propPart);
338
339 const valsKey = getValsKey(id, persistedProp, persistence);
340 let originalVal = extract(props[propName]);
341 const newVal = extract(newProps[propName]);
342
343 // mainly for nested props with multiple persisted parts, it's
344 // possible to have the same value as before - should not store
345 // in this case.
346 if (originalVal !== newVal) {
347 if (storage.hasItem(valsKey)) {
348 originalVal = storage.getItem(valsKey)[1];
349 }
350 const vals =
351 originalVal === undefined
352 ? [newVal]
353 : [newVal, originalVal];
354 storage.setItem(valsKey, vals, dispatch);
355 }
356 }
357 }, persisted_props);
358}
359
360/*
361 * Used for entire layouts (on load) or partial layouts (from children

Callers 2

updatePropsFunction · 0.90

Calls 7

getStoreFunction · 0.85
getTransformFunction · 0.85
getValsKeyFunction · 0.85
getPropsFunction · 0.70
hasItemMethod · 0.45
getItemMethod · 0.45
setItemMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…