Rematch plugin for maintaining timestamps when an effect is triggered.
Updated is primarily used for optimizing effects. It can be used to:
- prevent expensive fetch requests within a certain time period
- throttle effects
Install the correct version of the updated plugin based on the version of the core Rematch library in your project.
The updated plugin accepts one optional argument - config, which is an object with the following properties:
name(string): the key for the updated state. Default value is
blacklist(string): list of blacklisted model names, for which the plugin will not track effects
dateCreator(() => any): by default it's a function which returns new Date object when an effect is called. However, if you prefer to use moment or any other custom library, you can provide a custom implementation, such as
() => moment().
Let’s say we have a model ‘count’ in our store which has two effects - fetchOne and fetchTwo. Updated plugin’s state will have the following format:
To use the plugin, start with adding it to your store:
Define a model which uses effects.
Use the updated state: