Interface ActionTrackingMiddleware

Action tracking middleware hooks.

interface ActionTrackingMiddleware {
    filter(ctx: SimpleActionContext): boolean;
    onFinish(
        ctx: SimpleActionContext,
        ret: ActionTrackingReturn,
    ): void | ActionTrackingReturn;
    onResume(ctx: SimpleActionContext): void;
    onStart(ctx: SimpleActionContext): void | ActionTrackingReturn;
    onSuspend(ctx: SimpleActionContext): void;
}

Methods

  • Filter function called whenever each action starts, and only then.

    If the action is accepted then onStart, onResume, onSuspend and onFinish for that particular action will be called.

    All actions are accepted by default if no filter function is present.

    Parameters

    Returns boolean

    true to accept the action, false to skip it.

  • Called when an action just resumed a synchronous piece of code execution. Gets called once for sync actions and multiple times for flows.

    Parameters

    Returns void

  • Called when an action just started.

    Parameters

    Returns void | ActionTrackingReturn

    Can optionally return a result that will cancel the original action and finish it with the returned value / error to be thrown. In either case case resume / suspend / finish will still be called normally.

  • Called when an action just finished a synchronous pice of code execution. Note that this doesn't necessarily mean the action is finished. Gets called once for sync actions and multiple times for flows.

    Parameters

    Returns void