Making Data Accessible to Multiple Pages

Hello everyone,

I do have some previous experience with R/Shiny, but now want to use Dash for a project I’m currently working on. However, there seem to be some differences how global state is handled and I struggle to find a good way to do what I want.

What I want to do is the following:

  1. Create a multipage app.
  2. On one page of the multipage app I want the user to set some parameters which are then used to create (and show) some (more or less random) mock data in the form of a Pandas dataframe.
  3. On the other pages of the app I want to make use of the previously created mock data.
  4. When I switch back to the page where I created the mock data, I want to see the data, which was created the last time, until the user generates new data deliberately.

Points 1&2 work very well and I can set up my mock data in the way I want easily.

However, I’m not sure, how to handle points 3 and 4. The canonical way to handle point 3 seems to be dcc.Store, but this is subject to severe size constraints, according to the documentation. Is there another way to make data items, like, e.g., the aforementioned dataframe accessible from several pages?

And when it comes to point 4, I did not find a way to leave the generated mock data as it is. I was able to fix the previously selected settings of the different components by means of the persistence parameter, but based on these settings, upon calling the page again, my mock data is created again, randomly.

Please apologize, if my question is too unspecific, but at the current point for me it seems like I’m seeking for an overall approach, how to making data accessible to multiple pages. Please let me know, if you need more specific information or code.

Thanks very much in advance for your help!

Regards,

Thomas

Hi @TBu81, welcome to the forums.

You’re right, the use of dcc.Store() is the way to go. If you have concerns regarding size limitations, you could use the ServerSideOutput of dash-extensions

Regarding your last point, there was a forum thread not too long ago if I remember correctly, you could use the forum search. This topic comes up quite often.

1 Like

hi @TBu81 ,
Is generating the mock data a time/resource consuming operation? Why not serve it from server every time the user switches to that page? You could cache the function which generates the mock data to make things faster.

1 Like

Hi idling-mind,

thanks for the idea - this is probably the way I’ll go!

Regards,

Thomas