Action Chain Utils
import { getMetaData, removeAllMeta, removeMeta } from '@zedux/react'
Zedux exports a few functions that it uses internally when working with ActionChain objects. The only one you should probably ever use is removeAllMeta()
.
getMetaData
Finds a .metaData
value in the given ActionChain.
Signature:
getMetaData = (actionChain, metaType) => metaData
Required. The ActionChain object to search.
Required. A string that matches (===) the .metaType
property of a node in the ActionChain.
The .metaData
value of the first node with the given .metaType
.
removeAllMeta
Returns the action wrapped by the given ActionChain object.
This is the one you might find useful. Effects subscribers of composed stores receive ActionChain objects that you won't usually care about, except when implementing time travel. Use this to remove the ActionMeta nodes and get the raw action.
Actions are ActionChains. You can pass actions to this function, which will do nothing but return the passed action.
Signature:
removeAllMeta = actionChain => action
Required. The ActionChain object to unwrap.
The action object that the passed chain was wrapping. If the passed chain is an action, returns the action as-is.
removeMeta
Removes a single ActionMeta node in the given ActionChain by metaType
.
Signature:
removeMeta = (actionChain, metaType) => newChain
Required. The ActionChain object to modify.
Required. A string matching a .metaType
property of an ActionMeta node in the given ActionChain.
A brand new ActionChain object with the first matched ActionMeta node removed.