📣 Announcing the Storage component

In your example, after clicking btn the local storage should contain two keys:

store: dict(A1B2C3 = 2)
store-timestamp: [some epochtime]

As far as I can tell, when I start a new session, the following are true:

  • output will be empty (modified_timestamp doesn’t get triggered until a button is clicked)
  • State('store', 'data') = None
  • State('store', 'modified_timestamp') = None

I don’t care as much about output. How do I get State(‘store’, ‘data’) to reflect what was written to storage during the previous session?

In my case, I’m trying something like this with an interval that fires every 30s.

@app.callback(
    Output('store', 'data'),
    [Input('store-update', 'n_intervals')],
    [State('store', 'modified_timestamp'),
     State('store', 'data')]
)
def test_store_object(n, last_updated, data):
    print('last_updated:\t{}'.format(last_updated))
    print('data:\t{}'.format(data))
    raise PreventUpdate

The print statements report both as None, even though data has been saved to the appropriate keys in Local Storage.

1 Like