persistence

Redux-rest-easy works out-of-the-box with libraries such as redux-offline and redux-persist. However, the library will need to clean the state before persisting it, so that it never ends up in an inconsistent shape.

Here is a list of actions performed when you call getPersistableState:

  • In-progress requests are deleted. This is to avoid pending requests never resolving.

  • Expired and invalidated requests are deleted. This is to avoid keeping outdated requests possibly forever.

  • Requests with expireAt set to never (cacheLifetime set to Infinity) are invalidated. This is to avoid trusting remote data forever. Can still be done via persistOptions.alwaysPersist

  • Resources which are no longer referenced by any request are deleted. This is to avoidkeeping outdated resources in the state.

  • resolversHashes which refer to no longer existing requests or modified resources are deleted. This is to avoidkeeping outdated hashes in the state.

The first action is mandatory to avoid inconsistent state, but the others won't be applied to requests performing on resources defined in persistOptions.alwaysPersist and persistOptions.neverPersist. Instead, such requests will always/never be persisted.

Last updated