(
dispatch: any,
clientside_function: any,
config: any,
payload: ICallbackPayload
)
| 247 | } |
| 248 | |
| 249 | async function handleClientside( |
| 250 | dispatch: any, |
| 251 | clientside_function: any, |
| 252 | config: any, |
| 253 | payload: ICallbackPayload |
| 254 | ) { |
| 255 | const dc = ((window as any).dash_clientside = |
| 256 | (window as any).dash_clientside || {}); |
| 257 | if (!dc.no_update) { |
| 258 | Object.defineProperty(dc, 'no_update', { |
| 259 | value: {description: 'Return to prevent updating an Output.'}, |
| 260 | writable: false |
| 261 | }); |
| 262 | |
| 263 | Object.defineProperty(dc, 'PreventUpdate', { |
| 264 | value: {description: 'Throw to prevent updating all Outputs.'}, |
| 265 | writable: false |
| 266 | }); |
| 267 | } |
| 268 | |
| 269 | const {inputs, outputs, state} = payload; |
| 270 | const requestTime = Date.now(); |
| 271 | |
| 272 | const inputDict = inputsToDict(inputs); |
| 273 | const stateDict = inputsToDict(state); |
| 274 | const result: any = {}; |
| 275 | let status: any = STATUS.OK; |
| 276 | |
| 277 | try { |
| 278 | const {namespace, function_name} = clientside_function; |
| 279 | let args = inputs.map(getVals); |
| 280 | if (state) { |
| 281 | args = concat(args, state.map(getVals)); |
| 282 | } |
| 283 | |
| 284 | // setup callback context |
| 285 | dc.callback_context = {}; |
| 286 | dc.callback_context.triggered = payload.changedPropIds.map(prop_id => ({ |
| 287 | prop_id: prop_id, |
| 288 | value: inputDict[prop_id] |
| 289 | })); |
| 290 | dc.callback_context.triggered_id = getTriggeredId( |
| 291 | payload.changedPropIds |
| 292 | ); |
| 293 | dc.callback_context.inputs_list = inputs; |
| 294 | dc.callback_context.inputs = inputDict; |
| 295 | dc.callback_context.states_list = state; |
| 296 | dc.callback_context.states = stateDict; |
| 297 | dc.callback_context.outputs_list = outputs; |
| 298 | |
| 299 | let returnValue = dc[namespace][function_name](...args); |
| 300 | |
| 301 | delete dc.callback_context; |
| 302 | |
| 303 | if (typeof returnValue?.then === 'function') { |
| 304 | returnValue = await returnValue; |
| 305 | } |
| 306 |
no test coverage detected
searching dependent graphs…