Skip to content

Clientside PreventUpdate and no_update #963

Closed

Description

@jjaraalm

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.

Activity

  1. alexcjohnson commented on Oct 11, 2019

    @alexcjohnson
    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.

  2. jjaraalm commented on Oct 12, 2019

    @jjaraalm
    ContributorAuthor

    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?

  3. alexcjohnson commented on Oct 13, 2019

    @alexcjohnson
    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.

  4. jjaraalm commented on Oct 14, 2019

    @jjaraalm
    ContributorAuthor

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

  5. added a commit that references this issue on May 28, 2021
  6. added a commit that references this issue on Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions