-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Reproducible Sample
import type { AnyEventObject } from 'xstate';
import { fromCallback, setup } from 'xstate';
const SomeActor = fromCallback<AnyEventObject, { thing: string }>(({ input }) => {
console.log('SomeActor', input);
});
const AnotherActor = fromCallback<AnyEventObject, { otherThing: string }>(({ input }) => {
console.log('AnotherActor', input);
});
export const MyMachine = setup({
types: {
children: {} as { someActor: 'SomeActor'; anotherActor: 'AnotherActor' },
},
actions: {},
actors: {
AnotherActor: AnotherActor,
SomeActor: SomeActor,
},
}).createMachine({
id: 'ambient-noise-monitor',
initial: 'Starting',
invoke: [
{
id: 'someActor',
systemId: 'my-actor-system-id',
src: 'SomeActor',
input: () => ({ thing: 'left' }),
onError: {
target: '.State Two',
},
},
{
id: 'anotherActor',
systemId: 'my-actor-system-id',
src: 'AnotherActor',
input: () => ({ otherThing: 'SomeEvent' }),
onError: {
target: '.State Two',
},
},
],
states: {
Starting: {},
'State Two': {
type: 'final',
},
},
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels