covidgreen / covid-green-app

Apache License 2.0
297 stars 54 forks source link

Manage all persistence in the application provider #30

Open jackdclark opened 4 years ago

jackdclark commented 4 years ago

The way we read from & write to AsyncStorage/SecureStore in some components makes the state flow quite hard to follow. I think it would be nice if all of it was managed by the application provider, like we do for some things already in the setContext function. Then we can treat the application context as the source of truth for these values in our components & just ensure they’re synced with storage in the provider.

We do this already for some values (see https://github.com/covidgreen/covid-green-app/blob/current/providers/context.tsx#L225-L239). Can we improve this and make it easier to identify what's persisted? Something along the lines of the way you tell redux-persist that a certain branch of your application state should be persisted.