Output on session storage type does not trigger callback

Hi team,
In my Index.py that is how we navigate through different pages:

@app.callback(
    [Output('page-content', 'children'), Output('user-id', 'data'), Output('session-id', 'data')],
    [Input('url', 'pathname')],
    [State('user-id', 'data'), State('session-id', 'data')]
)
def display_page(pathname, user_id, session_id):
 if pathname == '/apps/dashboard':
   from apps.dashboard import dashboard
   return dashboard.layout, user_id, session_id
 if pathname == '/apps/home_page':
   return home_page.layout, user_id, session_id
 if pathname == '/apps/logout':
    return logout(), user_id, session_id

In my dashboard page, I use Input(‘user-id’, ‘data’) to load data. But although on every dashboard page load, I return ‘user-id’, sometimes it does not get updated and as a result Input(‘user-id’, ‘data’) does not get triggered. ‘user-id’ is a storage session type.

Thanks,

Yes, I think a callback will only be triggered by Input(‘user-id’, ‘data’) if the contents of the store actually change. You could maybe put both the userid and the url (in a dictionary) in the store?

1 Like