@@ -98,6 +98,27 @@ class _NoUpdate(object):
98
98
"""
99
99
100
100
101
+ def _handle_callback_args (* args ):
102
+ """Split args into outputs, inputs and states"""
103
+ args = [
104
+ arg
105
+ # for backward compatibility, one arg can be a list
106
+ for arg_or_list in args
107
+ # flatten args that are lists
108
+ for arg in (
109
+ arg_or_list if isinstance (arg_or_list , (list , tuple ))
110
+ else [arg_or_list ])
111
+ ]
112
+ return [
113
+ # split according to type Output, Input, State
114
+ [arg for arg in args if isinstance (arg , class_ )]
115
+ for class_ in [Output , Input , State ]
116
+ ] + [
117
+ # keep list of args in order, for matching order
118
+ # in the callback's parameters
119
+ [arg for arg in args if not isinstance (arg , Output )]]
120
+
121
+
101
122
# pylint: disable=too-many-instance-attributes
102
123
# pylint: disable=too-many-arguments, too-many-locals
103
124
class Dash (object ):
@@ -861,7 +882,7 @@ def clientside_callback(self, clientside_function, *args):
861
882
)
862
883
```
863
884
"""
864
- output , inputs , state , callback_args = self . _handle_callback_args (* args )
885
+ output , inputs , state , callback_args = _handle_callback_args (* args )
865
886
self ._insert_callback (output , inputs , state , callback_args )
866
887
867
888
# If JS source is explicitly given, create a namespace and function
@@ -893,28 +914,8 @@ def clientside_callback(self, clientside_function, *args):
893
914
"function_name" : function_name ,
894
915
}
895
916
896
- def _handle_callback_args (self , * args ):
897
- """Split args into outputs, inputs and states"""
898
- args = [
899
- arg
900
- # for backward compatibility, one arg can be a list
901
- for arg_or_list in args
902
- # flatten args that are lists
903
- for arg in (
904
- arg_or_list if isinstance (arg_or_list , (list , tuple ))
905
- else [arg_or_list ])
906
- ]
907
- return [
908
- # split according to type Output, Input, State
909
- [arg for arg in args if isinstance (arg , class_ )]
910
- for class_ in [Output , Input , State ]
911
- ] + [
912
- # keep list of args in order, for matching order
913
- # in the callback's parameters
914
- [arg for arg in args if not isinstance (arg , Output )]]
915
-
916
917
def callback (self , * args ):
917
- output , inputs , state , callback_args = self . _handle_callback_args (* args )
918
+ output , inputs , state , callback_args = _handle_callback_args (* args )
918
919
callback_id = self ._insert_callback (output , inputs , state , callback_args )
919
920
920
921
def wrap_func (func ):
0 commit comments