redux-persist-transform-expire icon indicating copy to clipboard operation
redux-persist-transform-expire copied to clipboard

Default state at per reducer level

Open skyshader opened this issue 7 years ago • 3 comments

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?

skyshader avatar Jun 13 '17 13:06 skyshader

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

gabceb avatar Jun 13 '17 14:06 gabceb

https://github.com/iou90/redux-persist-transform-expire try this.

iou90 avatar Jun 14 '17 01:06 iou90

@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.

skyshader avatar Jun 14 '17 10:06 skyshader