How do I load the initial app state from the database using ReSwift?
I'm thinking something like a middleware for when the app state is first being initialized, i.e., the first time the reducers are called.
How do I load the initial app state from the database using ReSwift?
I'm thinking something like a middleware for when the app state is first being initialized, i.e., the first time the reducers are called.
I think the solution is the Middleware.
Mean this, you can make an Action
with name InitializeApp
for example.
Create too a Middleware
like DataBaseMiddleware
.
Inside your Middleware
you can create a conditional to check if action
is InitializeApp
, and get the data from DataBase
after load completed you can dispatch
actions to update your States
.
Think inside your middleware you can dispatch UpdateUserInfo(name, age), UpdatePreferences..
I hope I was helpful.