Skip to content
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

[Feature Request] Global set_props in backend callbacks. #2803

Closed
T4rk1n opened this issue Mar 20, 2024 · 2 comments · Fixed by #2822
Closed

[Feature Request] Global set_props in backend callbacks. #2803

T4rk1n opened this issue Mar 20, 2024 · 2 comments · Fixed by #2822
Assignees

Comments

@T4rk1n
Copy link
Contributor

T4rk1n commented Mar 20, 2024

Add a global dash.set_props to be used in callbacks to set arbitrary props not defined in the callbacks outputs, similar to the clientside dash_clientside.set_props.

Example:

app.layout =  html.Div([
    html.Div(id="output"),
    html.Div(id="secondary-output"),
    html.Button("click", id="clicker"),
])

@app.callback(
    Output("output", "children"),
    Input("clicker", "n_clicks"),
    prevent_initial_call=True,
)
def on_click(n_clicks):
    set_props("secondary-output", {"children": "secondary"})
    return f"Clicked {n_clicks} times"
@T4rk1n T4rk1n self-assigned this Mar 20, 2024
@BSd3v
Copy link
Contributor

BSd3v commented Mar 21, 2024

Are you thinking this will be implemented and responding back alongside the same callback method? Or will this set_props immediately trigger something on the clientside?

@T4rk1n
Copy link
Contributor Author

T4rk1n commented Mar 21, 2024

Are you thinking this will be implemented and responding back alongside the same callback method? Or will this set_props immediately trigger something on the clientside?

For regular callback I am planning on adding the new props to the callback response data, on the renderer side this update the layout at the same as the rest of the outputs.

For background callback, adding a cached set_props value to retrieve on requests and apply as side update like the set_progress, independent of the output response.

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