Is AppState the best place to hold cache/historical data?

Hi,
What is the essential role of the AppState, supporting only the visible stack or it may contains also the cache/historical data?

For example, what to do with recent visited data that was previously fetched from a backend?

Note that by “recent visited data” I mean text and images fetched during the duration of a session. It might be much more than just a couple of uimages and a few strings. Of course if we need to keep data between sessions we need to persist the data somewhere.

I can think in a few options about where to keep it:

  • app state
  • storage service (dependency) that then may store the data in CoreData/Realm, filesystem or keep it in memory. I think the FirebaseSDK has this behaviour.
  • rely on HTTP cache (if the network client used support it)
  • never cache anything locally, fetch again from network

My gut feeling is that if it's only session data, it's fine to keep it in AppState.
Any other thoughts?

Many thanks
Jorge

AppState should hold business data relevant to the current, well, app state. Caching is environmental thing. Store it where you will (core data, sqlite, user defaults, network), but I believe in your case it's best to use environment to fetch the historical data and store it in a current screen's state when it's actually needed.