Skip to main content

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
actionChain

Required. The ActionChain object to search.

metaType

Required. A string that matches (===) the .metaType property of a node in the ActionChain.

Returns

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.

note

Actions are ActionChains. You can pass actions to this function, which will do nothing but return the passed action.

Signature:

removeAllMeta = actionChain => action
actionChain

Required. The ActionChain object to unwrap.

Returns

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
actionChain

Required. The ActionChain object to modify.

metaType

Required. A string matching a .metaType property of an ActionMeta node in the given ActionChain.

Returns

A brand new ActionChain object with the first matched ActionMeta node removed.

See Also