Skip to content

Clientside PreventUpdate and no_update #963

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

Closed
jjaraalm opened this issue Oct 11, 2019 · 4 comments · Fixed by #964
Closed

Clientside PreventUpdate and no_update #963

jjaraalm opened this issue Oct 11, 2019 · 4 comments · Fixed by #964

Comments

@jjaraalm
Copy link
Contributor

It would be helpful for clientside callbacks to be able to conditionally update components. This is not supported right now (as far as I can tell). This should be pretty simple, my idea would be to define

window.dash_clientside.no_update = {};

then in updateClientsideOutput just conditionally block updating by adding

if(window.dash_clientside.no_update && outputValue === window.dash_clientside.no_update)
    return;

Similarly we could define window.dash_clientside.PreventUpdate and allow the use of

throw window.dash_clientside.PreventUpdate;

If this seems reasonable I could put together a PR.

@alexcjohnson
Copy link
Collaborator

Good idea! Yes, I think everything you're proposing makes sense, feel free to make a PR. One thing I'd add then is that no_update and PreventUpdate need to be forbidden as namespaces in dash_clientside.

@jjaraalm
Copy link
Contributor Author

Yes, this is what I wanted to get feedback on first. I'm not sure that dash_clientside is actually the best place to put these as we expect it to be modified by users. The only way I see to do this reliably is to insert no_update and PreventUpdate as non-writable attributes after all user callbacks are loaded (practically, just insert them before invoking any callbacks), but then what do we do if a user has already defined them? I guess just gracefully proceed as if no_update and PreventUpdate didn't exist, otherwise it could be a breaking change.

Is there a better namespace to put these in?

@alexcjohnson
Copy link
Collaborator

I think that’s the right place. Yes, you could argue that forbidding those two names is a breaking change, but it seems to me extremely unlikely anyone has used those as a namespace so far. I’d put a check on the Python side that errors if those namespaces are referenced, and add them to dash_clientside during callback invocation.

@jjaraalm
Copy link
Contributor Author

Sounds like a plan. I'll put one together shortly.

@jjaraalm jjaraalm mentioned this issue Oct 15, 2019
8 tasks
HammadTheOne pushed a commit to HammadTheOne/dash that referenced this issue May 28, 2021
HammadTheOne pushed a commit that referenced this issue Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants