Skip to main content

Interface: ActionTrackingMiddleware

Action tracking middleware hooks.

Methods​

filter()?​

optional filter(ctx): boolean;

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​

ParameterTypeDescription
ctxSimpleActionContextSimplified action context.

Returns​

boolean

true to accept the action, false to skip it.


onFinish()?​

optional onFinish(ctx, ret): void | ActionTrackingReturn;

Called when an action just finished, either by returning normally or by throwing an error.

Parameters​

ParameterTypeDescription
ctxSimpleActionContextSimplified action context.
retActionTrackingReturnAction return result.

Returns​

void | ActionTrackingReturn

Can optionally return a new result that will override the original one.


onResume()?​

optional onResume(ctx): void;

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

Parameters​

ParameterTypeDescription
ctxSimpleActionContextSimplified action context.

Returns​

void


onStart()?​

optional onStart(ctx): void | ActionTrackingReturn;

Called when an action just started.

Parameters​

ParameterTypeDescription
ctxSimpleActionContextSimplified action context.

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.


onSuspend()?​

optional onSuspend(ctx): void;

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​

ParameterTypeDescription
ctxSimpleActionContextSimplified action context.

Returns​

void