Closed jdolle closed 6 years ago
You would only get this method to execute on rehydration of redux persist. Can you add the logic on a saga/thunk that happens after that action is fired?
That makes sense and sounds like a good solution. Thanks!
If there is a better way to do this then please comment, but I am now doing:
const unsubscribe = persistor.subscribe(() => {
const { bootstrapped } = persistor.getState();
if (bootstrapped) {
if (store.getState().exampleState.persistExpiresAt === undefined) {
store.dispatch(fetchExampleStateAction());
}
unsubscribe();
}
});
When the state expires, I want to fetch new state from my API. I'd prefer to not duplicate the time checking logic -- so I'd like to have an option to call a method on expiration, allowing me to make a request to my api then dispatch an action to set the redux state (and therefore persist the new state).