applyMiddleware

Applies one or more middleware that will be called for each dispatched action message. For more about what middleware is and how to implement it, see the section on middleware.

Usage

applyMiddleware([...middlewares])

Arguments

  • middlewares (Middleware): Optional. One or more middleware functions to apply.

Example

function traceMiddleware(next: DispatchFunction, actionMessage: ActionMessage) {
    console.log("Dispatching action: " + actionMessage.type);
    next(actionMessage);
}

applyMiddleware(traceMiddleware);

Notes

  • Calling applyMiddleware replaces any existing middleware.
  • If called without arguments, applyMiddleware removes all middleware.
  • Dispatched actions pass through each middleware in the order they are provided.

results matching ""

    No results matching ""