0.0.2 • Published 7 years ago

redux-persist-transform-expire-immutable v0.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

redux-persist-transform-expire-immutable

npm

Add expiration to your persisted store.

Usage

import createExpirationTransform from 'redux-persist-transform-expire-immutable';

const expireTransform = createExpirationTransform({
  expireKey: 'customExpiresAt',
  defaultState: {
    custom: 'values'
  }
});

persistStore(store, {
  transforms: [expireTransform]
});

Your expires key should be present in each reducer, which should be expired. E.g.

// top most reducer
{
  reducerOne: {
    persistExpiresAt: '2017-04-11T15:46:54.338Z'
  },
  reducerTwo: {
    persistExpiresAt: '2017-04-11T15:46:54.338Z'
  }
}

Configuration

AttrTypeDefaultNotes
expireKeyString'persistExpiresAt'Name of the attribute holding the expire date value
defaultStateAny{}Shape of the state after expirations happen