1 | import { EventObject, MachineContext, ActionArgs, ParameterizedObject } from "../types.js";
|
2 | type ResolvableSendId<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject> = string | ((args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams) => string);
|
3 | export interface CancelAction<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 | * Cancels a delayed `sendTo(...)` action that is waiting to be executed. The
|
8 | * canceled `sendTo(...)` action will not send its event or execute, unless the
|
9 | * `delay` has already elapsed before `cancel(...)` is called.
|
10 | *
|
11 | * @example
|
12 | *
|
13 | * ```ts
|
14 | * import { createMachine, sendTo, cancel } from 'xstate';
|
15 | *
|
16 | * const machine = createMachine({
|
17 | *
|
18 | * on: {
|
19 | * sendEvent: {
|
20 | * actions: sendTo(
|
21 | * 'some-actor',
|
22 | * { type: 'someEvent' },
|
23 | * {
|
24 | * id: 'some-id',
|
25 | * delay: 1000
|
26 | * }
|
27 | * )
|
28 | * },
|
29 | * cancelEvent: {
|
30 | * actions: cancel('some-id')
|
31 | * }
|
32 | * }
|
33 | * });
|
34 | * ```
|
35 | *
|
36 | * @param sendId The `id` of the `sendTo(...)` action to cancel.
|
37 | */
|
38 | export declare function cancel<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject>(sendId: ResolvableSendId<TContext, TExpressionEvent, TParams, TEvent>): CancelAction<TContext, TExpressionEvent, TParams, TEvent>;
|
39 | export {};
|
40 |
|
\ | No newline at end of file |