Modules: redux-listeners-middleware

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
setupFuncs setupFunction | Array.<setupFunction>

An array of setup functions or a single setup function that adds listeners for redux actions. See setupFunction for more info.

Source:
Returns:

A middleware function that can be passed to Redux's applyMiddleware()

Type
function

Type Definitions


addListenerFunction(options, handler)

Parameters:
Name Type Description
options object
Properties
Name Type Argument Description
actionType string | 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.

filter function | Array.<function()> <optional>

A function or array of functions that filter the incoming actions. Receives the following parameters:

  • action The action object
  • getState A function that can be called to get the current Redux state

Should return true if the handler function should be called.

handler function

Handler function that will be called when an action is dispatched that matches this listener.

Source:

setupFunction(addListener)

This callback will be called by reduxListenersMiddleware on initialization. Inside of it you can attach multiple action listeners by calling the addListener function.

Parameters:
Name Type Description
addListener addListenerFunction

Callback that can be used to add a new action listener. See addListenerFunction

Source: