Skip to content

Instantly share code, notes, and snippets.

@radiodario
Last active July 5, 2022 08:28
Show Gist options
  • Save radiodario/b3fcf6496f29ed9f7cf4b496ccf496dd to your computer and use it in GitHub Desktop.
Save radiodario/b3fcf6496f29ed9f7cf4b496ccf496dd to your computer and use it in GitHub Desktop.
import { createMachine } from 'xstate';
import { lightStates, cameraStates, micStates } from '@services/calling/sampleMachine/subStates';
const mainMachine = createMachine({
tsTypes: {} as import('./mainMachine.typegen').Typegen0,
schema: {
context: {} as { foo: number },
events: {} as { type: 'BOOM' } | { type: 'ON' } | { type: 'OFF' },
},
id: 'mainMachine',
initial: 'init',
context: {
foo: 0,
},
states: {
init: {
on: {
BOOM: 'middle',
},
},
middle: {
type: 'parallel',
on: {
BOOM: 'done',
},
states: {
lights: {
...lightStates,
},
camera: {
...cameraStates,
},
mic: {
...micStates,
},
},
},
done: {
type: 'final',
},
},
});
export default mainMachine;
// This file was automatically generated. Edits will be overwritten
export interface Typegen0 {
'@@xstate/typegen': true;
eventsCausingActions: {};
internalEvents: {
'xstate.init': { type: 'xstate.init' };
};
invokeSrcNameMap: {};
missingImplementations: {
actions: never;
services: never;
guards: never;
delays: never;
};
eventsCausingServices: {};
eventsCausingGuards: {};
eventsCausingDelays: {};
matchesStates:
| 'init'
| 'middle'
| 'middle.lights'
| 'middle.camera'
| 'middle.mic'
| 'done'
| { middle?: 'lights' | 'camera' | 'micStates' };
tags: never;
}
export const lightStates = {
initial: 'on',
states: {
on: {
on: {
OFF: 'off',
},
},
off: {
on: {
ON: 'on',
},
},
},
};
export const micStates = {
initial: 'on',
states: {
on: {
on: {
OFF: 'off',
},
},
off: {
on: {
ON: 'on',
},
},
},
};
export const cameraStates = {
initial: 'on',
states: {
on: {
on: {
OFF: 'off',
},
},
off: {
on: {
ON: 'on',
},
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment