Releases: lukebrandonfarrell/redux-persist-machine
v3.1.2
v3.1.1
v3.1.0
The package now exposes a function called getPersistMachineAction
, which takes a key to generate the action. This function generates an action name that uses the same standard of the generated name under the hood by the package.
getPersistMachineAction("user.orders")
would return @ReduxPM/LoadUserOrders
.
Full example:
import { getPersistMachineAction } from 'redux-persist-machine'
case getPersistMachineAction('user.subscriptionOrders'): {
return {
...state,
...action.payload,
};
}
The option to add your own custom action name is, of course, still available.
v3.0.1
The standard for generating action names has been changed. This only applies to the scenarios that a custom action name was not specified.
Before, if we had an reducer called orders
, we'd have a generated action name of LOAD_ORDERS
. Now, it is @ReduxPM/LoadOrders
, as in this manner it's easier to differentiate ordinary actions from the project actions.
v3.0.0
persistMiddleware
was removed. It is now returned fromcreatePersistMachine
- 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.
v2.1.0
- If nothing is provided to the
values
property when specifying which fields to keep track of, all fields will be tracked. - Added support for automatic loading without having to manually dispatch the action.