Skip to content

Commit 250352a

Browse files
mbegelalexcjohnson
authored andcommitted
Allow single Input not in a list
1 parent 439e13b commit 250352a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dash/dash.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def _insert_callback(self, output, inputs, state, prevent_initial_call):
846846
return callback_id
847847

848848
def clientside_callback(
849-
self, clientside_function, output, inputs, state=(), prevent_initial_call=None
849+
self, clientside_function, output, input, state=(), prevent_initial_call=None
850850
):
851851
"""Create a callback that updates the output by calling a clientside
852852
(JavaScript) function instead of a Python function.
@@ -912,6 +912,9 @@ def clientside_callback(
912912
not to fire when its outputs are first added to the page. Defaults to
913913
`False` unless `prevent_initial_callbacks=True` at the app level.
914914
"""
915+
is_multi_input = isinstance(input, (list, tuple))
916+
inputs = input if is_multi_input else [input]
917+
915918
self._insert_callback(output, inputs, state, prevent_initial_call)
916919

917920
# If JS source is explicitly given, create a namespace and function
@@ -943,7 +946,7 @@ def clientside_callback(
943946
"function_name": function_name,
944947
}
945948

946-
def callback(self, output, inputs, state=(), prevent_initial_call=None):
949+
def callback(self, output, input, state=(), prevent_initial_call=None):
947950
"""
948951
Normally used as a decorator, `@app.callback` provides a server-side
949952
callback relating the values of one or more `output` items to one or
@@ -955,6 +958,8 @@ def callback(self, output, inputs, state=(), prevent_initial_call=None):
955958
not to fire when its outputs are first added to the page. Defaults to
956959
`False` unless `prevent_initial_callbacks=True` at the app level.
957960
"""
961+
is_multi_input = isinstance(input, (list, tuple))
962+
inputs = input if is_multi_input else [input]
958963
callback_id = self._insert_callback(output, inputs, state, prevent_initial_call)
959964
multi = isinstance(output, (list, tuple))
960965

0 commit comments

Comments
 (0)