xstate 5.32.1 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -8
- package/dist/StateMachine-47e60715.esm.js +720 -0
- package/dist/StateMachine-48dcad8f.cjs.js +723 -0
- package/dist/StateMachine-6e063ac1.development.cjs.js +740 -0
- package/dist/StateMachine-6ec50e21.development.esm.js +737 -0
- package/dist/declarations/src/State.d.ts +11 -13
- package/dist/declarations/src/StateMachine.d.ts +27 -21
- package/dist/declarations/src/StateNode.d.ts +18 -54
- package/dist/declarations/src/actions.d.ts +14 -9
- package/dist/declarations/src/actors/callback.d.ts +42 -16
- package/dist/declarations/src/actors/index.d.ts +9 -6
- package/dist/declarations/src/actors/listener.d.ts +18 -0
- package/dist/declarations/src/actors/logic.d.ts +105 -0
- package/dist/declarations/src/actors/observable.d.ts +72 -27
- package/dist/declarations/src/actors/promise.d.ts +133 -48
- package/dist/declarations/src/actors/subscription.d.ts +22 -0
- package/dist/declarations/src/atom.d.ts +81 -0
- package/dist/declarations/src/createActor.d.ts +31 -33
- package/dist/declarations/src/createMachine.d.ts +35 -7
- package/dist/declarations/src/createMachineFromConfig.d.ts +176 -0
- package/dist/declarations/src/graph/graph.d.ts +4 -2
- package/dist/declarations/src/index.d.ts +12 -8
- package/dist/declarations/src/inspection.d.ts +84 -30
- package/dist/declarations/src/mapState.d.ts +4 -2
- package/dist/declarations/src/schema.types.d.ts +90 -0
- package/dist/declarations/src/serialize.d.ts +44 -0
- package/dist/declarations/src/setup.d.ts +251 -135
- package/dist/declarations/src/spawn.d.ts +6 -31
- package/dist/declarations/src/stateUtils.d.ts +21 -19
- package/dist/declarations/src/system.d.ts +8 -7
- package/dist/declarations/src/transition.d.ts +5 -5
- package/dist/declarations/src/types.d.ts +405 -405
- package/dist/declarations/src/types.v6.d.ts +392 -0
- package/dist/declarations/src/utils.d.ts +4 -3
- package/dist/index-39259ea4.development.esm.js +4948 -0
- package/dist/index-688701ed.esm.js +4909 -0
- package/dist/index-c35824b4.development.cjs.js +5007 -0
- package/dist/index-f0d7107d.cjs.js +4968 -0
- package/dist/xstate-actors.cjs.js +12 -838
- package/dist/xstate-actors.cjs.mjs +10 -5
- package/dist/xstate-actors.development.cjs.js +12 -838
- package/dist/xstate-actors.development.cjs.mjs +10 -5
- package/dist/xstate-actors.development.esm.js +1 -836
- package/dist/xstate-actors.esm.js +1 -836
- package/dist/xstate-actors.umd.min.js +1 -1
- package/dist/xstate-actors.umd.min.js.map +1 -1
- package/dist/xstate-graph.cjs.js +18 -29
- package/dist/xstate-graph.development.cjs.js +18 -29
- package/dist/xstate-graph.development.esm.js +15 -26
- package/dist/xstate-graph.esm.js +15 -26
- package/dist/xstate-graph.umd.min.js +1 -1
- package/dist/xstate-graph.umd.min.js.map +1 -1
- package/dist/xstate.cjs.js +1316 -112
- package/dist/xstate.cjs.mjs +22 -22
- package/dist/xstate.development.cjs.js +1316 -112
- package/dist/xstate.development.cjs.mjs +22 -22
- package/dist/xstate.development.esm.js +1278 -76
- package/dist/xstate.esm.js +1278 -76
- package/dist/xstate.umd.min.js +1 -1
- package/dist/xstate.umd.min.js.map +1 -1
- package/package.json +3 -47
- package/dist/StateMachine-45e79c35.esm.js +0 -560
- package/dist/StateMachine-be2e51a3.development.cjs.js +0 -569
- package/dist/StateMachine-e0178d48.development.esm.js +0 -566
- package/dist/StateMachine-e6732977.cjs.js +0 -563
- package/dist/assign-2aa58daa.esm.js +0 -127
- package/dist/assign-927227d6.development.cjs.js +0 -135
- package/dist/assign-e8f2bd75.cjs.js +0 -129
- package/dist/assign-f338cee3.development.esm.js +0 -133
- package/dist/declarations/src/actions/assign.d.ts +0 -45
- package/dist/declarations/src/actions/cancel.d.ts +0 -39
- package/dist/declarations/src/actions/emit.d.ts +0 -44
- package/dist/declarations/src/actions/enqueueActions.d.ts +0 -57
- package/dist/declarations/src/actions/log.d.ts +0 -16
- package/dist/declarations/src/actions/raise.d.ts +0 -21
- package/dist/declarations/src/actions/send.d.ts +0 -42
- package/dist/declarations/src/actions/spawnChild.d.ts +0 -34
- package/dist/declarations/src/actions/stopChild.d.ts +0 -19
- package/dist/declarations/src/actors/transition.d.ts +0 -143
- package/dist/declarations/src/dev/index.d.ts +0 -14
- package/dist/declarations/src/guards.d.ts +0 -128
- package/dist/log-410e5e55.development.esm.js +0 -429
- package/dist/log-7776fcf2.cjs.js +0 -409
- package/dist/log-c2e11c01.development.cjs.js +0 -437
- package/dist/log-fa75ec2d.esm.js +0 -401
- package/dist/raise-74097812.development.esm.js +0 -2823
- package/dist/raise-7c948725.cjs.js +0 -2816
- package/dist/raise-964cd4e9.development.cjs.js +0 -2878
- package/dist/raise-e974d1c9.esm.js +0 -2761
- package/dist/xstate-actions.cjs.d.mts +0 -2
- package/dist/xstate-actions.cjs.d.ts +0 -2
- package/dist/xstate-actions.cjs.js +0 -23
- package/dist/xstate-actions.cjs.mjs +0 -14
- package/dist/xstate-actions.development.cjs.js +0 -23
- package/dist/xstate-actions.development.cjs.mjs +0 -14
- package/dist/xstate-actions.development.esm.js +0 -4
- package/dist/xstate-actions.esm.js +0 -4
- package/dist/xstate-actions.umd.min.js +0 -2
- package/dist/xstate-actions.umd.min.js.map +0 -1
- package/dist/xstate-dev.cjs.d.mts +0 -2
- package/dist/xstate-dev.cjs.d.ts +0 -2
- package/dist/xstate-dev.cjs.js +0 -48
- package/dist/xstate-dev.cjs.mjs +0 -5
- package/dist/xstate-dev.development.cjs.js +0 -51
- package/dist/xstate-dev.development.cjs.mjs +0 -5
- package/dist/xstate-dev.development.esm.js +0 -45
- package/dist/xstate-dev.esm.js +0 -42
- package/dist/xstate-dev.umd.min.js +0 -2
- package/dist/xstate-dev.umd.min.js.map +0 -1
- package/dist/xstate-guards.cjs.d.mts +0 -2
- package/dist/xstate-guards.cjs.d.ts +0 -2
- package/dist/xstate-guards.cjs.js +0 -14
- package/dist/xstate-guards.cjs.mjs +0 -7
- package/dist/xstate-guards.development.cjs.js +0 -14
- package/dist/xstate-guards.development.cjs.mjs +0 -7
- package/dist/xstate-guards.development.esm.js +0 -2
- package/dist/xstate-guards.esm.js +0 -2
- package/dist/xstate-guards.umd.min.js +0 -2
- package/dist/xstate-guards.umd.min.js.map +0 -1
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dist_xstateGuards = require('./raise-964cd4e9.development.cjs.js');
|
|
4
|
-
|
|
5
|
-
function createSpawner(actorScope, {
|
|
6
|
-
machine,
|
|
7
|
-
context
|
|
8
|
-
}, event, spawnedChildren) {
|
|
9
|
-
const spawn = (src, options) => {
|
|
10
|
-
if (typeof src === 'string') {
|
|
11
|
-
const logic = dist_xstateGuards.resolveReferencedActor(machine, src);
|
|
12
|
-
if (!logic) {
|
|
13
|
-
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
14
|
-
}
|
|
15
|
-
const actorRef = dist_xstateGuards.createActor(logic, {
|
|
16
|
-
id: options?.id,
|
|
17
|
-
parent: actorScope.self,
|
|
18
|
-
syncSnapshot: options?.syncSnapshot,
|
|
19
|
-
input: typeof options?.input === 'function' ? options.input({
|
|
20
|
-
context,
|
|
21
|
-
event,
|
|
22
|
-
self: actorScope.self
|
|
23
|
-
}) : options?.input,
|
|
24
|
-
src,
|
|
25
|
-
systemId: options?.systemId
|
|
26
|
-
});
|
|
27
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
28
|
-
return actorRef;
|
|
29
|
-
} else {
|
|
30
|
-
const actorRef = dist_xstateGuards.createActor(src, {
|
|
31
|
-
id: options?.id,
|
|
32
|
-
parent: actorScope.self,
|
|
33
|
-
syncSnapshot: options?.syncSnapshot,
|
|
34
|
-
input: options?.input,
|
|
35
|
-
src,
|
|
36
|
-
systemId: options?.systemId
|
|
37
|
-
});
|
|
38
|
-
return actorRef;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return (src, options) => {
|
|
42
|
-
const actorRef = spawn(src, options); // TODO: fix types
|
|
43
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
44
|
-
actorScope.defer(() => {
|
|
45
|
-
if (actorRef._processingStatus === dist_xstateGuards.ProcessingStatus.Stopped) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
actorRef.start();
|
|
49
|
-
});
|
|
50
|
-
return actorRef;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
55
|
-
assignment
|
|
56
|
-
}) {
|
|
57
|
-
if (!snapshot.context) {
|
|
58
|
-
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
59
|
-
}
|
|
60
|
-
const spawnedChildren = {};
|
|
61
|
-
const assignArgs = {
|
|
62
|
-
context: snapshot.context,
|
|
63
|
-
event: actionArgs.event,
|
|
64
|
-
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
65
|
-
self: actorScope.self,
|
|
66
|
-
system: actorScope.system
|
|
67
|
-
};
|
|
68
|
-
let partialUpdate = {};
|
|
69
|
-
if (typeof assignment === 'function') {
|
|
70
|
-
partialUpdate = assignment(assignArgs, actionParams);
|
|
71
|
-
} else {
|
|
72
|
-
for (const key of Object.keys(assignment)) {
|
|
73
|
-
const propAssignment = assignment[key];
|
|
74
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
78
|
-
return [dist_xstateGuards.cloneMachineSnapshot(snapshot, {
|
|
79
|
-
context: updatedContext,
|
|
80
|
-
children: Object.keys(spawnedChildren).length ? {
|
|
81
|
-
...snapshot.children,
|
|
82
|
-
...spawnedChildren
|
|
83
|
-
} : snapshot.children
|
|
84
|
-
}), undefined, undefined];
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Updates the current context of the machine.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* import { createMachine, assign } from 'xstate';
|
|
93
|
-
*
|
|
94
|
-
* const countMachine = createMachine({
|
|
95
|
-
* context: {
|
|
96
|
-
* count: 0,
|
|
97
|
-
* message: ''
|
|
98
|
-
* },
|
|
99
|
-
* on: {
|
|
100
|
-
* inc: {
|
|
101
|
-
* actions: assign({
|
|
102
|
-
* count: ({ context }) => context.count + 1
|
|
103
|
-
* })
|
|
104
|
-
* },
|
|
105
|
-
* updateMessage: {
|
|
106
|
-
* actions: assign(({ context, event }) => {
|
|
107
|
-
* return {
|
|
108
|
-
* message: event.message.trim()
|
|
109
|
-
* };
|
|
110
|
-
* })
|
|
111
|
-
* }
|
|
112
|
-
* }
|
|
113
|
-
* });
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* @param assignment An object that represents the partial context to update, or
|
|
117
|
-
* a function that returns an object that represents the partial context to
|
|
118
|
-
* update.
|
|
119
|
-
*/
|
|
120
|
-
function assign(assignment) {
|
|
121
|
-
if (dist_xstateGuards.executingCustomAction) {
|
|
122
|
-
console.warn('Custom actions should not call `assign()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
123
|
-
}
|
|
124
|
-
function assign(_args, _params) {
|
|
125
|
-
{
|
|
126
|
-
throw new Error(`This isn't supposed to be called`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
assign.type = 'xstate.assign';
|
|
130
|
-
assign.assignment = assignment;
|
|
131
|
-
assign.resolve = resolveAssign;
|
|
132
|
-
return assign;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
exports.assign = assign;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var dist_xstateGuards = require('./raise-7c948725.cjs.js');
|
|
4
|
-
|
|
5
|
-
function createSpawner(actorScope, {
|
|
6
|
-
machine,
|
|
7
|
-
context
|
|
8
|
-
}, event, spawnedChildren) {
|
|
9
|
-
const spawn = (src, options) => {
|
|
10
|
-
if (typeof src === 'string') {
|
|
11
|
-
const logic = dist_xstateGuards.resolveReferencedActor(machine, src);
|
|
12
|
-
if (!logic) {
|
|
13
|
-
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
14
|
-
}
|
|
15
|
-
const actorRef = dist_xstateGuards.createActor(logic, {
|
|
16
|
-
id: options?.id,
|
|
17
|
-
parent: actorScope.self,
|
|
18
|
-
syncSnapshot: options?.syncSnapshot,
|
|
19
|
-
input: typeof options?.input === 'function' ? options.input({
|
|
20
|
-
context,
|
|
21
|
-
event,
|
|
22
|
-
self: actorScope.self
|
|
23
|
-
}) : options?.input,
|
|
24
|
-
src,
|
|
25
|
-
systemId: options?.systemId
|
|
26
|
-
});
|
|
27
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
28
|
-
return actorRef;
|
|
29
|
-
} else {
|
|
30
|
-
const actorRef = dist_xstateGuards.createActor(src, {
|
|
31
|
-
id: options?.id,
|
|
32
|
-
parent: actorScope.self,
|
|
33
|
-
syncSnapshot: options?.syncSnapshot,
|
|
34
|
-
input: options?.input,
|
|
35
|
-
src,
|
|
36
|
-
systemId: options?.systemId
|
|
37
|
-
});
|
|
38
|
-
return actorRef;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return (src, options) => {
|
|
42
|
-
const actorRef = spawn(src, options); // TODO: fix types
|
|
43
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
44
|
-
actorScope.defer(() => {
|
|
45
|
-
if (actorRef._processingStatus === dist_xstateGuards.ProcessingStatus.Stopped) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
actorRef.start();
|
|
49
|
-
});
|
|
50
|
-
return actorRef;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
55
|
-
assignment
|
|
56
|
-
}) {
|
|
57
|
-
if (!snapshot.context) {
|
|
58
|
-
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
59
|
-
}
|
|
60
|
-
const spawnedChildren = {};
|
|
61
|
-
const assignArgs = {
|
|
62
|
-
context: snapshot.context,
|
|
63
|
-
event: actionArgs.event,
|
|
64
|
-
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
65
|
-
self: actorScope.self,
|
|
66
|
-
system: actorScope.system
|
|
67
|
-
};
|
|
68
|
-
let partialUpdate = {};
|
|
69
|
-
if (typeof assignment === 'function') {
|
|
70
|
-
partialUpdate = assignment(assignArgs, actionParams);
|
|
71
|
-
} else {
|
|
72
|
-
for (const key of Object.keys(assignment)) {
|
|
73
|
-
const propAssignment = assignment[key];
|
|
74
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
78
|
-
return [dist_xstateGuards.cloneMachineSnapshot(snapshot, {
|
|
79
|
-
context: updatedContext,
|
|
80
|
-
children: Object.keys(spawnedChildren).length ? {
|
|
81
|
-
...snapshot.children,
|
|
82
|
-
...spawnedChildren
|
|
83
|
-
} : snapshot.children
|
|
84
|
-
}), undefined, undefined];
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Updates the current context of the machine.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* import { createMachine, assign } from 'xstate';
|
|
93
|
-
*
|
|
94
|
-
* const countMachine = createMachine({
|
|
95
|
-
* context: {
|
|
96
|
-
* count: 0,
|
|
97
|
-
* message: ''
|
|
98
|
-
* },
|
|
99
|
-
* on: {
|
|
100
|
-
* inc: {
|
|
101
|
-
* actions: assign({
|
|
102
|
-
* count: ({ context }) => context.count + 1
|
|
103
|
-
* })
|
|
104
|
-
* },
|
|
105
|
-
* updateMessage: {
|
|
106
|
-
* actions: assign(({ context, event }) => {
|
|
107
|
-
* return {
|
|
108
|
-
* message: event.message.trim()
|
|
109
|
-
* };
|
|
110
|
-
* })
|
|
111
|
-
* }
|
|
112
|
-
* }
|
|
113
|
-
* });
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* @param assignment An object that represents the partial context to update, or
|
|
117
|
-
* a function that returns an object that represents the partial context to
|
|
118
|
-
* update.
|
|
119
|
-
*/
|
|
120
|
-
function assign(assignment) {
|
|
121
|
-
function assign(_args, _params) {
|
|
122
|
-
}
|
|
123
|
-
assign.type = 'xstate.assign';
|
|
124
|
-
assign.assignment = assignment;
|
|
125
|
-
assign.resolve = resolveAssign;
|
|
126
|
-
return assign;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
exports.assign = assign;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { _ as ProcessingStatus, V as resolveReferencedActor, c as createActor, a0 as cloneMachineSnapshot, W as executingCustomAction } from './raise-74097812.development.esm.js';
|
|
2
|
-
|
|
3
|
-
function createSpawner(actorScope, {
|
|
4
|
-
machine,
|
|
5
|
-
context
|
|
6
|
-
}, event, spawnedChildren) {
|
|
7
|
-
const spawn = (src, options) => {
|
|
8
|
-
if (typeof src === 'string') {
|
|
9
|
-
const logic = resolveReferencedActor(machine, src);
|
|
10
|
-
if (!logic) {
|
|
11
|
-
throw new Error(`Actor logic '${src}' not implemented in machine '${machine.id}'`);
|
|
12
|
-
}
|
|
13
|
-
const actorRef = createActor(logic, {
|
|
14
|
-
id: options?.id,
|
|
15
|
-
parent: actorScope.self,
|
|
16
|
-
syncSnapshot: options?.syncSnapshot,
|
|
17
|
-
input: typeof options?.input === 'function' ? options.input({
|
|
18
|
-
context,
|
|
19
|
-
event,
|
|
20
|
-
self: actorScope.self
|
|
21
|
-
}) : options?.input,
|
|
22
|
-
src,
|
|
23
|
-
systemId: options?.systemId
|
|
24
|
-
});
|
|
25
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
26
|
-
return actorRef;
|
|
27
|
-
} else {
|
|
28
|
-
const actorRef = createActor(src, {
|
|
29
|
-
id: options?.id,
|
|
30
|
-
parent: actorScope.self,
|
|
31
|
-
syncSnapshot: options?.syncSnapshot,
|
|
32
|
-
input: options?.input,
|
|
33
|
-
src,
|
|
34
|
-
systemId: options?.systemId
|
|
35
|
-
});
|
|
36
|
-
return actorRef;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
return (src, options) => {
|
|
40
|
-
const actorRef = spawn(src, options); // TODO: fix types
|
|
41
|
-
spawnedChildren[actorRef.id] = actorRef;
|
|
42
|
-
actorScope.defer(() => {
|
|
43
|
-
if (actorRef._processingStatus === ProcessingStatus.Stopped) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
actorRef.start();
|
|
47
|
-
});
|
|
48
|
-
return actorRef;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function resolveAssign(actorScope, snapshot, actionArgs, actionParams, {
|
|
53
|
-
assignment
|
|
54
|
-
}) {
|
|
55
|
-
if (!snapshot.context) {
|
|
56
|
-
throw new Error('Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.');
|
|
57
|
-
}
|
|
58
|
-
const spawnedChildren = {};
|
|
59
|
-
const assignArgs = {
|
|
60
|
-
context: snapshot.context,
|
|
61
|
-
event: actionArgs.event,
|
|
62
|
-
spawn: createSpawner(actorScope, snapshot, actionArgs.event, spawnedChildren),
|
|
63
|
-
self: actorScope.self,
|
|
64
|
-
system: actorScope.system
|
|
65
|
-
};
|
|
66
|
-
let partialUpdate = {};
|
|
67
|
-
if (typeof assignment === 'function') {
|
|
68
|
-
partialUpdate = assignment(assignArgs, actionParams);
|
|
69
|
-
} else {
|
|
70
|
-
for (const key of Object.keys(assignment)) {
|
|
71
|
-
const propAssignment = assignment[key];
|
|
72
|
-
partialUpdate[key] = typeof propAssignment === 'function' ? propAssignment(assignArgs, actionParams) : propAssignment;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const updatedContext = Object.assign({}, snapshot.context, partialUpdate);
|
|
76
|
-
return [cloneMachineSnapshot(snapshot, {
|
|
77
|
-
context: updatedContext,
|
|
78
|
-
children: Object.keys(spawnedChildren).length ? {
|
|
79
|
-
...snapshot.children,
|
|
80
|
-
...spawnedChildren
|
|
81
|
-
} : snapshot.children
|
|
82
|
-
}), undefined, undefined];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Updates the current context of the machine.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
*
|
|
89
|
-
* ```ts
|
|
90
|
-
* import { createMachine, assign } from 'xstate';
|
|
91
|
-
*
|
|
92
|
-
* const countMachine = createMachine({
|
|
93
|
-
* context: {
|
|
94
|
-
* count: 0,
|
|
95
|
-
* message: ''
|
|
96
|
-
* },
|
|
97
|
-
* on: {
|
|
98
|
-
* inc: {
|
|
99
|
-
* actions: assign({
|
|
100
|
-
* count: ({ context }) => context.count + 1
|
|
101
|
-
* })
|
|
102
|
-
* },
|
|
103
|
-
* updateMessage: {
|
|
104
|
-
* actions: assign(({ context, event }) => {
|
|
105
|
-
* return {
|
|
106
|
-
* message: event.message.trim()
|
|
107
|
-
* };
|
|
108
|
-
* })
|
|
109
|
-
* }
|
|
110
|
-
* }
|
|
111
|
-
* });
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @param assignment An object that represents the partial context to update, or
|
|
115
|
-
* a function that returns an object that represents the partial context to
|
|
116
|
-
* update.
|
|
117
|
-
*/
|
|
118
|
-
function assign(assignment) {
|
|
119
|
-
if (executingCustomAction) {
|
|
120
|
-
console.warn('Custom actions should not call `assign()` directly, as it is not imperative. See https://stately.ai/docs/actions#built-in-actions for more details.');
|
|
121
|
-
}
|
|
122
|
-
function assign(_args, _params) {
|
|
123
|
-
{
|
|
124
|
-
throw new Error(`This isn't supposed to be called`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
assign.type = 'xstate.assign';
|
|
128
|
-
assign.assignment = assignment;
|
|
129
|
-
assign.resolve = resolveAssign;
|
|
130
|
-
return assign;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { assign as a };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Spawner } from "../spawn.js";
|
|
2
|
-
import type { ActionArgs, AnyEventObject, Assigner, EventObject, LowInfer, MachineContext, ParameterizedObject, PropertyAssigner, ProvidedActor, ActionFunction } from "../types.js";
|
|
3
|
-
export interface AssignArgs<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TActor extends ProvidedActor> extends ActionArgs<TContext, TExpressionEvent, TEvent> {
|
|
4
|
-
spawn: Spawner<TActor>;
|
|
5
|
-
}
|
|
6
|
-
export interface AssignAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TActor extends ProvidedActor> {
|
|
7
|
-
(args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
|
|
8
|
-
_out_TActor?: TActor;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Updates the current context of the machine.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { createMachine, assign } from 'xstate';
|
|
17
|
-
*
|
|
18
|
-
* const countMachine = createMachine({
|
|
19
|
-
* context: {
|
|
20
|
-
* count: 0,
|
|
21
|
-
* message: ''
|
|
22
|
-
* },
|
|
23
|
-
* on: {
|
|
24
|
-
* inc: {
|
|
25
|
-
* actions: assign({
|
|
26
|
-
* count: ({ context }) => context.count + 1
|
|
27
|
-
* })
|
|
28
|
-
* },
|
|
29
|
-
* updateMessage: {
|
|
30
|
-
* actions: assign(({ context, event }) => {
|
|
31
|
-
* return {
|
|
32
|
-
* message: event.message.trim()
|
|
33
|
-
* };
|
|
34
|
-
* })
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @param assignment An object that represents the partial context to update, or
|
|
41
|
-
* a function that returns an object that represents the partial context to
|
|
42
|
-
* update.
|
|
43
|
-
*/
|
|
44
|
-
export declare function assign<TContext extends MachineContext, TExpressionEvent extends AnyEventObject, // TODO: consider using a stricter `EventObject` here
|
|
45
|
-
TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TActor extends ProvidedActor>(assignment: Assigner<LowInfer<TContext>, TExpressionEvent, TParams, TEvent, TActor> | PropertyAssigner<LowInfer<TContext>, TExpressionEvent, TParams, TEvent, TActor>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, TActor, never, never, never, never>;
|
|
@@ -1,39 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ActionArgs, ActionFunction, AnyEventObject, DoNotInfer, EventObject, MachineContext, ParameterizedObject, SendExpr } from "../types.js";
|
|
2
|
-
export interface EmitAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TEmitted extends EventObject> {
|
|
3
|
-
(args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
|
|
4
|
-
_out_TEmitted?: TEmitted;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Emits an event to event handlers registered on the actor via `actor.on(event,
|
|
8
|
-
* handler)`.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { emit } from 'xstate';
|
|
14
|
-
*
|
|
15
|
-
* const machine = createMachine({
|
|
16
|
-
* // ...
|
|
17
|
-
* on: {
|
|
18
|
-
* something: {
|
|
19
|
-
* actions: emit({
|
|
20
|
-
* type: 'emitted',
|
|
21
|
-
* some: 'data'
|
|
22
|
-
* })
|
|
23
|
-
* }
|
|
24
|
-
* }
|
|
25
|
-
* // ...
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* const actor = createActor(machine).start();
|
|
29
|
-
*
|
|
30
|
-
* actor.on('emitted', (event) => {
|
|
31
|
-
* console.log(event);
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* actor.send({ type: 'something' });
|
|
35
|
-
* // logs:
|
|
36
|
-
* // {
|
|
37
|
-
* // type: 'emitted',
|
|
38
|
-
* // some: 'data'
|
|
39
|
-
* // }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function emit<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TEmitted extends AnyEventObject>(
|
|
43
|
-
/** The event to emit, or an expression that returns an event to emit. */
|
|
44
|
-
eventOrExpr: DoNotInfer<TEmitted> | SendExpr<TContext, TExpressionEvent, TParams, DoNotInfer<TEmitted>, TEvent>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, never, never, never, never, TEmitted>;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Guard } from "../guards.js";
|
|
2
|
-
import { Action, ActionArgs, ActionFunction, AnyActorRef, AnyEventObject, EventObject, MachineContext, ParameterizedObject, ProvidedActor, UnifiedArg } from "../types.js";
|
|
3
|
-
import { assign } from "./assign.js";
|
|
4
|
-
import { cancel } from "./cancel.js";
|
|
5
|
-
import { emit } from "./emit.js";
|
|
6
|
-
import { raise } from "./raise.js";
|
|
7
|
-
import { sendParent, sendTo } from "./send.js";
|
|
8
|
-
import { spawnChild } from "./spawnChild.js";
|
|
9
|
-
import { stopChild } from "./stopChild.js";
|
|
10
|
-
interface ActionEnqueuer<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TEmitted extends EventObject> {
|
|
11
|
-
(action: Action<TContext, TExpressionEvent, TEvent, undefined, TActor, TAction, TGuard, TDelay, TEmitted>): void;
|
|
12
|
-
assign: (...args: Parameters<typeof assign<TContext, TExpressionEvent, undefined, TEvent, TActor>>) => void;
|
|
13
|
-
cancel: (...args: Parameters<typeof cancel<TContext, TExpressionEvent, undefined, TEvent>>) => void;
|
|
14
|
-
raise: (...args: Parameters<typeof raise<TContext, TExpressionEvent, TEvent, undefined, TDelay, TDelay>>) => void;
|
|
15
|
-
sendTo: <TTargetActor extends AnyActorRef>(...args: Parameters<typeof sendTo<TContext, TExpressionEvent, undefined, TTargetActor, TEvent, TDelay, TDelay>>) => void;
|
|
16
|
-
sendParent: (...args: Parameters<typeof sendParent<TContext, TExpressionEvent, undefined, AnyEventObject, TEvent, TDelay, TDelay>>) => void;
|
|
17
|
-
spawnChild: (...args: Parameters<typeof spawnChild<TContext, TExpressionEvent, undefined, TEvent, TActor>>) => void;
|
|
18
|
-
stopChild: (...args: Parameters<typeof stopChild<TContext, TExpressionEvent, undefined, TEvent>>) => void;
|
|
19
|
-
emit: (...args: Parameters<typeof emit<TContext, TExpressionEvent, undefined, TEvent, TEmitted>>) => void;
|
|
20
|
-
}
|
|
21
|
-
export interface EnqueueActionsAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string> {
|
|
22
|
-
(args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
|
|
23
|
-
_out_TEvent?: TEvent;
|
|
24
|
-
_out_TActor?: TActor;
|
|
25
|
-
_out_TAction?: TAction;
|
|
26
|
-
_out_TGuard?: TGuard;
|
|
27
|
-
_out_TDelay?: TDelay;
|
|
28
|
-
}
|
|
29
|
-
interface CollectActionsArg<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TEmitted extends EventObject> extends UnifiedArg<TContext, TExpressionEvent, TEvent> {
|
|
30
|
-
check: (guard: Guard<TContext, TExpressionEvent, undefined, TGuard>) => boolean;
|
|
31
|
-
enqueue: ActionEnqueuer<TContext, TExpressionEvent, TEvent, TActor, TAction, TGuard, TDelay, TEmitted>;
|
|
32
|
-
}
|
|
33
|
-
type CollectActions<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TActor extends ProvidedActor, TAction extends ParameterizedObject, TGuard extends ParameterizedObject, TDelay extends string, TEmitted extends EventObject> = ({ context, event, check, enqueue, self }: CollectActionsArg<TContext, TExpressionEvent, TEvent, TActor, TAction, TGuard, TDelay, TEmitted>, params: TParams) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Creates an action object that will execute actions that are queued by the
|
|
36
|
-
* `enqueue(action)` function.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { createMachine, enqueueActions } from 'xstate';
|
|
42
|
-
*
|
|
43
|
-
* const machine = createMachine({
|
|
44
|
-
* entry: enqueueActions(({ enqueue, check }) => {
|
|
45
|
-
* enqueue.assign({ count: 0 });
|
|
46
|
-
*
|
|
47
|
-
* if (check('someGuard')) {
|
|
48
|
-
* enqueue.assign({ count: 1 });
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* enqueue('someAction');
|
|
52
|
-
* })
|
|
53
|
-
* });
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export declare function enqueueActions<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject = TExpressionEvent, TActor extends ProvidedActor = ProvidedActor, TAction extends ParameterizedObject = ParameterizedObject, TGuard extends ParameterizedObject = ParameterizedObject, TDelay extends string = never, TEmitted extends EventObject = EventObject>(collect: CollectActions<TContext, TExpressionEvent, TParams, TEvent, TActor, TAction, TGuard, TDelay, TEmitted>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, TActor, TAction, TGuard, TDelay, TEmitted>;
|
|
57
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ActionArgs, EventObject, LogExpr, MachineContext, ParameterizedObject } from "../types.js";
|
|
2
|
-
type ResolvableLogValue<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject> = string | LogExpr<TContext, TExpressionEvent, TParams, TEvent>;
|
|
3
|
-
export 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
|
-
*/
|
|
15
|
-
export 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>;
|
|
16
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ActionArgs, ActionFunction, DoNotInfer, EventObject, ExecutableActionObject, MachineContext, ParameterizedObject, RaiseActionOptions, SendExpr } from "../types.js";
|
|
2
|
-
export interface RaiseAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TDelay extends string> {
|
|
3
|
-
(args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
|
|
4
|
-
_out_TEvent?: TEvent;
|
|
5
|
-
_out_TDelay?: TDelay;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Raises an event. This places the event in the internal event queue, so that
|
|
9
|
-
* the event is immediately consumed by the machine in the current step.
|
|
10
|
-
*
|
|
11
|
-
* @param eventType The event to raise.
|
|
12
|
-
*/
|
|
13
|
-
export declare function raise<TContext extends MachineContext, TExpressionEvent extends EventObject, TEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TDelay extends string = never, TUsedDelay extends TDelay = never>(eventOrExpr: DoNotInfer<TEvent> | SendExpr<TContext, TExpressionEvent, TParams, DoNotInfer<TEvent>, TEvent>, options?: RaiseActionOptions<TContext, TExpressionEvent, TParams, DoNotInfer<TEvent>, TUsedDelay>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, never, never, never, TDelay, never>;
|
|
14
|
-
export interface ExecutableRaiseAction extends ExecutableActionObject {
|
|
15
|
-
type: 'xstate.raise';
|
|
16
|
-
params: {
|
|
17
|
-
event: EventObject;
|
|
18
|
-
id: string | undefined;
|
|
19
|
-
delay: number | undefined;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ActionArgs, ActionFunction, AnyActorRef, AnyEventObject, Cast, DoNotInfer, EventFrom, EventObject, ExecutableActionObject, InferEvent, MachineContext, ParameterizedObject, SendExpr, SendToActionOptions } from "../types.js";
|
|
2
|
-
export interface SendToAction<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TDelay extends string> {
|
|
3
|
-
(args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams): void;
|
|
4
|
-
_out_TDelay?: TDelay;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Sends an event to an actor.
|
|
8
|
-
*
|
|
9
|
-
* @param actor The `ActorRef` to send the event to.
|
|
10
|
-
* @param event The event to send, or an expression that evaluates to the event
|
|
11
|
-
* to send
|
|
12
|
-
* @param options Send action options
|
|
13
|
-
*
|
|
14
|
-
* - `id` - The unique send event identifier (used with `cancel()`).
|
|
15
|
-
* - `delay` - The number of milliseconds to delay the sending of the event.
|
|
16
|
-
*/
|
|
17
|
-
export declare function sendTo<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TTargetActor extends AnyActorRef, TEvent extends EventObject, TDelay extends string = never, TUsedDelay extends TDelay = never>(to: SendToActionTarget<TContext, TExpressionEvent, TParams, TTargetActor, TEvent>, eventOrExpr: EventFrom<TTargetActor> | SendExpr<TContext, TExpressionEvent, TParams, InferEvent<Cast<EventFrom<TTargetActor>, EventObject>>, TEvent>, options?: SendToActionOptions<TContext, TExpressionEvent, TParams, DoNotInfer<TEvent>, TUsedDelay>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, never, never, never, TDelay, never>;
|
|
18
|
-
/**
|
|
19
|
-
* Sends an event to this machine's parent.
|
|
20
|
-
*
|
|
21
|
-
* @param event The event to send to the parent machine.
|
|
22
|
-
* @param options Options to pass into the send event.
|
|
23
|
-
*/
|
|
24
|
-
export declare function sendParent<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TSentEvent extends EventObject = AnyEventObject, TEvent extends EventObject = AnyEventObject, TDelay extends string = never, TUsedDelay extends TDelay = never>(event: TSentEvent | SendExpr<TContext, TExpressionEvent, TParams, TSentEvent, TEvent>, options?: SendToActionOptions<TContext, TExpressionEvent, TParams, TEvent, TUsedDelay>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, never, never, never, TDelay, never>;
|
|
25
|
-
type SendToActionTarget<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TTargetActor extends AnyActorRef, TEvent extends EventObject> = string | TTargetActor | ((args: ActionArgs<TContext, TExpressionEvent, TEvent>, params: TParams) => string | TTargetActor);
|
|
26
|
-
/**
|
|
27
|
-
* Forwards (sends) an event to the `target` actor.
|
|
28
|
-
*
|
|
29
|
-
* @param target The target actor to forward the event to.
|
|
30
|
-
* @param options Options to pass into the send action creator.
|
|
31
|
-
*/
|
|
32
|
-
export declare function forwardTo<TContext extends MachineContext, TExpressionEvent extends EventObject, TParams extends ParameterizedObject['params'] | undefined, TEvent extends EventObject, TDelay extends string = never, TUsedDelay extends TDelay = never>(target: SendToActionTarget<TContext, TExpressionEvent, TParams, AnyActorRef, TEvent>, options?: SendToActionOptions<TContext, TExpressionEvent, TParams, TEvent, TUsedDelay>): ActionFunction<TContext, TExpressionEvent, TEvent, TParams, never, never, never, TDelay, never>;
|
|
33
|
-
export interface ExecutableSendToAction extends ExecutableActionObject {
|
|
34
|
-
type: 'xstate.sendTo';
|
|
35
|
-
params: {
|
|
36
|
-
event: EventObject;
|
|
37
|
-
id: string | undefined;
|
|
38
|
-
delay: number | undefined;
|
|
39
|
-
to: AnyActorRef;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export {};
|