Last active
July 5, 2022 08:28
-
-
Save radiodario/b3fcf6496f29ed9f7cf4b496ccf496dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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