30
30
import warnings
31
31
32
32
import dash
33
- from dash import Dash
33
+ from dash import Dash , dependencies
34
34
from dash ._utils import split_callback_id , inputs_to_dict
35
35
36
36
from flask import Flask
@@ -320,7 +320,7 @@ def get_expanded_arguments(func, inputs, state):
320
320
321
321
return expanded
322
322
323
- def callback (self , output , inputs = None , state = None , events = None ):
323
+ def callback (self , * _args , ** _kwargs ):
324
324
'''Form a callback function by wrapping, in the same way as the underlying Dash application would
325
325
but handling extra arguments provided by dpd.
326
326
@@ -331,10 +331,15 @@ def callback(self, output, inputs=None, state=None, events=None):
331
331
Otherwise, take all arguments beyond the one provided by Dash (based on the Inputs/States provided).
332
332
333
333
'''
334
+
335
+ output , inputs , state , prevent_initial_call = dependencies .handle_callback_args (
336
+ _args , _kwargs
337
+ )
338
+
334
339
callback_set = {'output' : output ,
335
- 'inputs' : inputs or [] ,
336
- 'state' : state or [] ,
337
- 'events ' : events or [] }
340
+ 'inputs' : inputs ,
341
+ 'state' : state ,
342
+ 'prevent_initial_call ' : prevent_initial_call }
338
343
339
344
def wrap_func (func ):
340
345
self ._callback_sets .append ((callback_set , func ))
@@ -348,12 +353,17 @@ def wrap_func(func):
348
353
349
354
expanded_callback = callback
350
355
351
- def clientside_callback (self , clientside_function , output , inputs = None , state = None ):
356
+ def clientside_callback (self , clientside_function , * _args , ** _kwargs ):
352
357
'Form a callback function by wrapping, in the same way as the underlying Dash application would'
358
+ output , inputs , state , prevent_initial_call = dependencies .handle_callback_args (
359
+ _args , _kwargs
360
+ )
361
+
353
362
callback_set = { 'clientside_function' : clientside_function ,
354
363
'output' : output ,
355
- 'inputs' : inputs and inputs or dict (),
356
- 'state' : state and state or dict () }
364
+ 'inputs' : inputs ,
365
+ 'state' : state ,
366
+ 'prevent_initial_call' : prevent_initial_call }
357
367
358
368
self ._clientside_callback_sets .append (callback_set )
359
369
@@ -589,7 +599,7 @@ def _fix_callback_item(self, item):
589
599
item .component_id = self ._fix_id (item .component_id )
590
600
return item
591
601
592
- def callback (self , output , inputs = [] , state = [], events = []): # pylint: disable=dangerous-default-value
602
+ def callback (self , output , inputs , state , prevent_initial_call ):
593
603
'Invoke callback, adjusting variable names as needed'
594
604
595
605
if isinstance (output , (list , tuple )):
@@ -599,9 +609,10 @@ def callback(self, output, inputs=[], state=[], events=[]): # pylint: disable=da
599
609
600
610
return super ().callback (fixed_outputs ,
601
611
[self ._fix_callback_item (x ) for x in inputs ],
602
- [self ._fix_callback_item (x ) for x in state ])
612
+ [self ._fix_callback_item (x ) for x in state ],
613
+ prevent_initial_call = prevent_initial_call )
603
614
604
- def clientside_callback (self , clientside_function , output , inputs = [] , state = [] ): # pylint: disable=dangerous-default-value
615
+ def clientside_callback (self , clientside_function , output , inputs , state , prevent_initial_call ): # pylint: disable=dangerous-default-value
605
616
'Invoke callback, adjusting variable names as needed'
606
617
607
618
if isinstance (output , (list , tuple )):
@@ -612,7 +623,8 @@ def clientside_callback(self, clientside_function, output, inputs=[], state=[]):
612
623
return super ().clientside_callback (clientside_function ,
613
624
fixed_outputs ,
614
625
[self ._fix_callback_item (x ) for x in inputs ],
615
- [self ._fix_callback_item (x ) for x in state ])
626
+ [self ._fix_callback_item (x ) for x in state ],
627
+ prevent_initial_call = prevent_initial_call )
616
628
617
629
#pylint: disable=too-many-locals
618
630
def dispatch_with_args (self , body , argMap ):
0 commit comments