-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Prevent initial call #1228
Prevent initial call #1228
Conversation
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.
💃
startsWith(chunkPath), | ||
pluck('path', flatten(cb.getOutputs(paths))) | ||
) | ||
) { | ||
cb.changedPropIds = {}; |
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.
I'm not sure what I was thinking here with clearing out changedPropIds
, but in this case (we've found a callback by its inputs due to a layout change, and just determined that all its outputs are in the same layout chunk) we know the callback is already included in the queue via its outputs so the best thing to do is simply not re-include it at all. This extra addCallback
was harmless before prevent_initial_call
, just a slight bit of extra work; but now that we have prevent_initial_call
it's possible this callback would not be added based on its outputs.
If this condition isn't met, there are outputs outside the new layout chunk and it's not in fact an initial call anyway - so it's appropriate to add the callback and that's what the new logic does.
{"clientside": False, "content": True, "global": False}, | ||
{"clientside": True, "content": True, "global": True}, | ||
{"clientside": False, "content": False, "global": True}, | ||
] |
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.
Initial impression is really good! Together with #832 we can avoid any unneeded calls, and have a very fast page load. |
Closes #1225
Supersedes #1123
Adds the ability to control whether or not callbacks fire when the page or layout chunk first loads. This can simplify a lot of code like
if n_clicks is None: raise PreventUpdate
, and it can improve loading performance, particularly for pattern-matching callbacks, where a page can easily generate hundreds of callback invocations, since there is no longer even a server call for these callbacks.This option is off by default, but can either be turned on for each callback independently:
or app-wide, in which case it can be turned off for individual callbacks:
CHANGELOG.md