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 canceled `sendTo(...)` action
|
8 | * will not send its event or execute, unless the `delay` has already elapsed before `cancel(...)` is called.
|
9 | *
|
10 | * @param sendId The `id` of the `sendTo(...)` action to cancel.
|
11 | *
|
12 | * @example
|
13 | ```ts
|
14 | import { createMachine, sendTo, cancel } from 'xstate';
|
15 |
|
16 | const machine = createMachine({
|
17 |
|
18 | on: {
|
19 | sendEvent: {
|
20 | actions: sendTo('some-actor', { type: 'someEvent' }, {
|
21 | id: 'some-id',
|
22 | delay: 1000
|
23 | })
|
24 | },
|
25 | cancelEvent: {
|
26 | actions: cancel('some-id')
|
27 | }
|
28 | }
|
29 | });
|
30 | ```
|
31 | */
|
32 | 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>;
|
33 | export {};
|
34 |
|
\ | No newline at end of file |