@@ -200,7 +200,7 @@ const getVals = (input: any) =>
200
200
const zipIfArray = ( a : any , b : any ) =>
201
201
Array . isArray ( a ) ? zip ( a , b ) : [ [ a , b ] ] ;
202
202
203
- function handleClientside (
203
+ async function handleClientside (
204
204
dispatch : any ,
205
205
clientside_function : any ,
206
206
config : any ,
@@ -246,14 +246,10 @@ function handleClientside(
246
246
dc . callback_context . states_list = state ;
247
247
dc . callback_context . states = stateDict ;
248
248
249
- const returnValue = dc [ namespace ] [ function_name ] ( ...args ) ;
249
+ let returnValue = dc [ namespace ] [ function_name ] ( ...args ) ;
250
250
251
251
if ( typeof returnValue ?. then === 'function' ) {
252
- throw new Error (
253
- 'The clientside function returned a Promise. ' +
254
- 'Promises are not supported in Dash clientside ' +
255
- 'right now, but may be in the future.'
256
- ) ;
252
+ returnValue = await returnValue ;
257
253
}
258
254
259
255
zipIfArray ( outputs , returnValue ) . forEach ( ( [ outi , reti ] ) => {
@@ -504,15 +500,13 @@ export function executeCallback(
504
500
505
501
if ( clientside_function ) {
506
502
try {
507
- return {
508
- data : handleClientside (
509
- dispatch ,
510
- clientside_function ,
511
- config ,
512
- payload
513
- ) ,
503
+ const data = await handleClientside (
504
+ dispatch ,
505
+ clientside_function ,
506
+ config ,
514
507
payload
515
- } ;
508
+ ) ;
509
+ return { data, payload} ;
516
510
} catch ( error : any ) {
517
511
return { error, payload} ;
518
512
}
0 commit comments