dash-auth icon indicating copy to clipboard operation
dash-auth copied to clipboard

Issue when clientside callback is defined before public callback

Open Godisemo opened this issue 11 months ago • 0 comments

Example app below. If the clientside callback is defined before the public callback the app crashes. If the order is reversed the app works as expected.

from dash import Dash, Input, Output, clientside_callback, dcc, html

from dash_auth import public_callback

app = Dash()
app.layout = html.Div(
    [
        dcc.Location(id="url"),
        html.Div(id="clientside-callback-output"),
        html.Div(id="public-callback-output"),
    ]
)


clientside_callback(
    "function (pathname) {return `Hello ${pathname} from clientside callback!`;}",
    Output("clientside-callback-output", "children"),
    Input("url", "pathname"),
)


@public_callback(
    Output("public-callback-output", "children"),
    Input("url", "pathname"),
)
def public(pathname: str) -> str:
    return f"Hello {pathname} from public callback!"


if __name__ == "__main__":
    app.run(debug=True)

Godisemo avatar Feb 03 '25 22:02 Godisemo