Methods
-
reduxListenersMiddleware(setupFuncs)
-
Redux middleware that can be used to attach listeners to Redux actions.
IMPORTANT: This should only be used to add additional side-effects to Redux actions, such as event tracking. Using this middleware to do application logic is an anti-pattern.
Parameters:
Name Type Description setupFuncssetupFunction | Array.<setupFunction> An array of setup functions or a single setup function that adds listeners for redux actions. See
setupFunctionfor more info.Returns:
A middleware function that can be passed to Redux's applyMiddleware()
- Type
- function
Type Definitions
-
addListenerFunction(options, handler)
-
Parameters:
Name Type Description optionsobject Properties
Name Type Argument Description actionTypestring | Array.<string> <optional>
An action type or array of action type that will be listened to. If not set, this listener will listen to any action type. However, for performance reasons it is recommended to add action types here whenever possible.
filterfunction | Array.<function()> <optional>
A function or array of functions that filter the incoming actions. Receives the following parameters:
actionThe action objectgetStateA function that can be called to get the current Redux state
Should return
trueif the handler function should be called.handlerfunction Handler function that will be called when an action is dispatched that matches this listener.
-
setupFunction(addListener)
-
This callback will be called by
reduxListenersMiddlewareon initialization. Inside of it you can attach multiple action listeners by calling the addListener function.Parameters:
Name Type Description addListeneraddListenerFunction Callback that can be used to add a new action listener. See
addListenerFunction