The loading plugin for Rematch. Adds automated loading indicators for effects, so you don't need to manage state like
loading: true by yourself. Inspired by dva-loading.
Install the correct version of loading plugin based on the version of the core Rematch library in your project.
The loading plugin accepts one optional argument - config, which is an object with the following properties:
name] (string?): key for the loading model in your store. If you name it "custom", loading state can be accessed from state.custom. Defaults to loading.
asNumber] (boolean?): loading plugin by default keeps track of running effects using booleans, so for example: state.loading.global === true. You can change that behaviour and use numbers instead - plugin will keep track of the number of times an effect was executed, for example: state.loading.global === 5. Defaults to false.
whitelist] (string?): an array of effects names that you want to use loading plugin for. If defined, plugin will work only for the whitelisted effects.
blacklist] (string?): an array of effects names that you don't want to use loading plugin for. If defined, plugin will work for all effects except those blacklisted.
whitelist accept the "full" effect name, in a format
modelName/effectFunctionName, for example 'count/addOne'.
whitelist aren't provided, plugin works for all effects.
Let's say we have a model 'count' in our store. Loading plugin's state will have the following format:
Check out below an example of how to use loading plugin in React:
Set up your store with default or custom settings.
Use state created by the loading plugin in your view.