kamranahmedse / redux-persist-expire

Expiring transformer for redux-persist
MIT License
78 stars 12 forks source link

Doesn't work like expected #16

Closed raul-saez closed 4 years ago

raul-saez commented 4 years ago

I'm having some trouble trying to integrate this. Here is how the config looks like:

const persistConfig = {
  key: "root",
  storage,
  transforms: [
    expireReducer('isSignedIn', {
      expiredState: false,
      expireSeconds: 10,
      autoExpire: true,
    }),
  ],
};

const persistedReducer = persistReducer(persistConfig, rootReducer); // This is the persist reducer that I'm then passing on to the store

isSignedIn can be true or false, when I execute this its state equals "{"__persisted_at":<EPOCH>}" I think it might not be working because on Redux isSignedIn is still true, I am most lickely doing something wrong.

qkreltms commented 4 years ago

It seems redux-persist-expire expires reducer key when some action is dispatched into the reducer. Why don't you dispatch an action and after 10 secs dispatch the action again and check whether isSignedIn is set to {}

raul-saez commented 4 years ago

@qkreltms Thanks for the response. The final time will be ~1 hour. I don't think that solution is feasible if by that you mean set a timeout in which I could just set the key to false myself without the need of redux-persist-expire, any other thoughts?

AdiBevoor commented 4 years ago

@kamranahmedse Can you please help on this?