Skip to content

Commit

Permalink
🔨 Rename callback->callback_context
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Feb 14, 2019
1 parent a239f7a commit ef420a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .version import __version__ # noqa: F401
from ._callback_context import CallbackContext as _CallbackContext

callback = _CallbackContext()
callback_context = _CallbackContext()
2 changes: 1 addition & 1 deletion dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ def dispatch(self):
'{}.{}'.format(x['id'], x['property']): x.get('value')
for x in state
}
flask.g.triggered_inputs = body.get('changedProps')
flask.g.triggered_inputs = body.get('changedPropIds')

for component_registration in self.callback_map[target_id]['inputs']:
args.append([
Expand Down
9 changes: 4 additions & 5 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,10 @@ def test_callback_context(self):
@app.callback(Output('output', 'children'),
[Input(x, 'n_clicks') for x in btns])
def on_click(*args):
print('wtf')
if not dash.callback.triggered:
if not dash.callback_context.triggered:
raise PreventUpdate
trigger = dash.callback.triggered[0]
input_value = dash.callback.inputs.get(trigger)
trigger = dash.callback_context.triggered[0]
input_value = dash.callback_context.inputs.get(trigger)
return 'Just clicked {} for the {} time!'.format(
trigger.split('.')[0], input_value
)
Expand All @@ -616,4 +615,4 @@ def on_click(*args):

def test_no_callback_context(self):
with self.assertRaises(MissingCallbackContextException):
no_context = dash.callback.inputs
no_context = dash.callback_context.inputs

0 comments on commit ef420a4

Please sign in to comment.