redux-persist-transform-expire
redux-persist-transform-expire copied to clipboard
Default state at per reducer level
The example shows how to provide default value at the time of creating an instance:
const expireTransform = createExpirationTransform({
expireKey: 'customExpiresAt',
defaultState: {
custom: 'values'
}
});
persistStore(store, {
transforms: [expireTransform]
});
Can I configure somehow the defaultState
to be defined at reducer level?
You can do this today by making sure your reducer alwags returns an expiration key on its root. If you want config level settings yo can put a PR together where a reducer name is passed along with a key and an expiration which is injected on the inbound function
https://github.com/iou90/redux-persist-transform-expire try this.
@iou90 Still all the config remains at one place, ie., at the time of creating an instance. I was wondering if the expiration triggers REHYDRATE in the affected reducers. If it does, I can set up the default state there itself. If not then this seems like a good solution.