MCPcopy
hub / github.com/plotly/dash / triggerDefaultState

Function triggerDefaultState

dash/dash-renderer/src/actions/index.js:85–156  ·  view source on GitHub ↗
(dispatch, getState)

Source from the content-addressed store, hash-verified

83}
84
85function triggerDefaultState(dispatch, getState) {
86 const {graphs, paths, layout} = getState();
87
88 // overallOrder will assert circular dependencies for multi output.
89 try {
90 graphs.MultiGraph.overallOrder();
91 } catch (err) {
92 dispatch(
93 onError({
94 type: 'backEnd',
95 error: {
96 message: 'Circular Dependencies',
97 html: err.toString()
98 }
99 })
100 );
101 }
102
103 const layoutCallbacks = getLayoutCallbacks(
104 graphs,
105 paths,
106 layout.components,
107 {
108 outputsOnly: true
109 }
110 );
111
112 // Also include no-output and no-input callbacks that should fire on initial load
113 const specialCallbacks = (graphs.callbacks || []).reduce((acc, cb) => {
114 if (cb.prevent_initial_call) {
115 return acc;
116 }
117
118 const isNoOutput = cb.noOutput;
119 const isNoInput = !cb.noOutput && cb.inputs.length === 0;
120
121 if (!isNoOutput && !isNoInput) {
122 return acc;
123 }
124
125 const resolved = makeResolvedCallback(cb, resolveDeps(), '');
126 resolved.initialCall = true;
127
128 if (isNoOutput) {
129 // No-output: include if no inputs or any input is in layout
130 if (cb.inputs.length === 0) {
131 acc.push(resolved);
132 } else {
133 const inputs = resolved.getInputs(paths);
134 if (
135 inputs.some(inp =>
136 Array.isArray(inp) ? inp.length > 0 : inp
137 )
138 ) {
139 acc.push(resolved);
140 }
141 }
142 } else {

Callers 1

hydrateInitialOutputsFunction · 0.85

Calls 7

getLayoutCallbacksFunction · 0.90
makeResolvedCallbackFunction · 0.90
resolveDepsFunction · 0.90
getStateFunction · 0.85
reduceMethod · 0.80
pushMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…