3030import warnings
3131
3232import dash
33- from dash import Dash
33+ from dash import Dash , dependencies
3434from dash ._utils import split_callback_id , inputs_to_dict
3535
3636from flask import Flask
@@ -320,7 +320,7 @@ def get_expanded_arguments(func, inputs, state):
320320
321321 return expanded
322322
323- def callback (self , output , inputs = None , state = None , events = None ):
323+ def callback (self , * _args , ** _kwargs ):
324324 '''Form a callback function by wrapping, in the same way as the underlying Dash application would
325325 but handling extra arguments provided by dpd.
326326
@@ -331,10 +331,15 @@ def callback(self, output, inputs=None, state=None, events=None):
331331 Otherwise, take all arguments beyond the one provided by Dash (based on the Inputs/States provided).
332332
333333 '''
334+
335+ output , inputs , state , prevent_initial_call = dependencies .handle_callback_args (
336+ _args , _kwargs
337+ )
338+
334339 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 }
338343
339344 def wrap_func (func ):
340345 self ._callback_sets .append ((callback_set , func ))
@@ -348,12 +353,17 @@ def wrap_func(func):
348353
349354 expanded_callback = callback
350355
351- def clientside_callback (self , clientside_function , output , inputs = None , state = None ):
356+ def clientside_callback (self , clientside_function , * _args , ** _kwargs ):
352357 '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+
353362 callback_set = { 'clientside_function' : clientside_function ,
354363 '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 }
357367
358368 self ._clientside_callback_sets .append (callback_set )
359369
@@ -589,7 +599,7 @@ def _fix_callback_item(self, item):
589599 item .component_id = self ._fix_id (item .component_id )
590600 return item
591601
592- def callback (self , output , inputs = [] , state = [], events = []): # pylint: disable=dangerous-default-value
602+ def callback (self , output , inputs , state , prevent_initial_call ):
593603 'Invoke callback, adjusting variable names as needed'
594604
595605 if isinstance (output , (list , tuple )):
@@ -599,9 +609,10 @@ def callback(self, output, inputs=[], state=[], events=[]): # pylint: disable=da
599609
600610 return super ().callback (fixed_outputs ,
601611 [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 )
603614
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
605616 'Invoke callback, adjusting variable names as needed'
606617
607618 if isinstance (output , (list , tuple )):
@@ -612,7 +623,8 @@ def clientside_callback(self, clientside_function, output, inputs=[], state=[]):
612623 return super ().clientside_callback (clientside_function ,
613624 fixed_outputs ,
614625 [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 )
616628
617629 #pylint: disable=too-many-locals
618630 def dispatch_with_args (self , body , argMap ):
0 commit comments