UNPKG

1.25 kBTypeScriptView Raw
1import { ActionArgs, EventObject, LogExpr, MachineContext, ParameterizedObject } from "../types.js";
2type ResolvableLogValue<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject> = string | LogExpr<TContext, TExpressionEvent, TParams, TEvent>;
3export interface LogAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject> {
4 (args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
5}
6/**
7 * @param expr The expression function to evaluate which will be logged. Takes
8 * in 2 arguments:
9 *
10 * - `ctx` - the current state context
11 * - `event` - the event that caused this action to be executed.
12 *
13 * @param label The label to give to the logged expression.
14 */
15export declare function log<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject>(value?: ResolvableLogValue<TContext, TExpressionEvent, TParams, TEvent>, label?: string): LogAction<TContext, TExpressionEvent, TParams, TEvent>;
16export {};