Skip to content

v3.0.0

Compare
Choose a tag to compare
@rodriigovieira rodriigovieira released this 08 Dec 17:27
· 16 commits to master since this release
  • persistMiddleware was removed. It is now returned from createPersistMachine
  • It is now necessary to call the persistMiddleware.run() method after setting up the store

This release has breaking changes to the package's API. Some changes were made to facilitate the setup process and make the steps more clear.

Migration guide from 2.0 to 3.0

In this new version, we don't export anymore the persistMiddleware. It is now returned from the createPersistMachine function.

This new version has two major steps to setup the library. First, setup the middleware, then the store, and lastly call the persistMiddleware.run(store) method.

const persistMiddleware = createPersistMachine(structure, saveMethod, loadMethod)
const middleware = [persistMiddleware]

const store = createStore(rootReducer, applyMiddleware(...[middleware]));

// Required step: call this function so we can save the state every time an action is triggered
persistMiddleware.run(store)

In the previous version, we were only passing the save and load function to the persistMiddleware function. This function no longer exists, and now all the arguments (structure, load/save methods, and whether to debug or not) are passed to the createPersistMachine.

And we also have to call persistMiddleware.run(store) so we can attach a listener to the store so it can be triggered every time the state changes.