-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Partial updates #680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial updates #680
Changes from all commits
928d4b4
fb0db30
b2a97b4
ba00dd7
681e8c5
0ee047e
ad42fa7
a0d17be
1689606
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -74,6 +74,15 @@ | |||||||||||
_re_renderer_scripts_id = re.compile(r'id="_dash-renderer') | ||||||||||||
|
||||||||||||
|
||||||||||||
class _NoUpdate(object): | ||||||||||||
# pylint: disable=too-few-public-methods | ||||||||||||
pass | ||||||||||||
|
||||||||||||
|
||||||||||||
# Singleton signal to not update an output, alternative to PreventUpdate | ||||||||||||
no_update = _NoUpdate() | ||||||||||||
|
||||||||||||
|
||||||||||||
# pylint: disable=too-many-instance-attributes | ||||||||||||
# pylint: disable=too-many-arguments, too-many-locals | ||||||||||||
class Dash(object): | ||||||||||||
|
@@ -1053,15 +1062,25 @@ def add_context(*args, **kwargs): | |||||||||||
) | ||||||||||||
|
||||||||||||
component_ids = collections.defaultdict(dict) | ||||||||||||
has_update = False | ||||||||||||
for i, o in enumerate(output): | ||||||||||||
component_ids[o.component_id][o.component_property] =\ | ||||||||||||
output_value[i] | ||||||||||||
val = output_value[i] | ||||||||||||
if val is not no_update: | ||||||||||||
has_update = True | ||||||||||||
o_id, o_prop = o.component_id, o.component_property | ||||||||||||
component_ids[o_id][o_prop] = val | ||||||||||||
|
||||||||||||
if not has_update: | ||||||||||||
raise exceptions.PreventUpdate | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what Lines 180 to 183 in bb5ed70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an empty 204 which would be the same as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually seems like
Which anyway sounds at least as complicated as what we're doing with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, 204 is not an error. But then you are at the dispatch level, think you can just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're in the weeds now - the return from this function feeds into Line 1094 in b2a97b4
There may be a way to improve on this but I'd like to defer it for this PR, if that's alright. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that's new. Anyway, this works well for partial updates. |
||||||||||||
|
||||||||||||
response = { | ||||||||||||
'response': component_ids, | ||||||||||||
'multi': True | ||||||||||||
} | ||||||||||||
else: | ||||||||||||
if output_value is no_update: | ||||||||||||
raise exceptions.PreventUpdate | ||||||||||||
|
||||||||||||
response = { | ||||||||||||
'response': { | ||||||||||||
'props': { | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad that we're returning a dict instead of a list here 😸 I was sure that we would've had to change the renderer to do this.