Function onActionMiddleware

  • Attaches an action middleware that invokes a listener for all actions of a given tree. Note that the listener will only be invoked for the topmost level actions, so it won't run for child actions or intermediary flow steps. Also it won't trigger the listener for calls to hooks such as onAttachedToRootStore or its returned disposer.

    Its main use is to keep track of top level actions that can be later replicated via applyAction somewhere else (another machine, etc.).

    There are two kind of possible listeners, onStart and onFinish listeners. onStart listeners are called before the action executes and allow cancellation by returning a new return value (which might be a return or a throw). onFinish listeners are called after the action executes, have access to the action actual return value and allow overriding by returning a new return value (which might be a return or a throw).

    If you want to ensure that the actual action calls are serializable you should use either serializeActionCallArgument over the arguments or serializeActionCall over the whole action before sending the action call over the wire / storing them .

    Parameters

    Returns ActionMiddlewareDisposer

    The middleware disposer.