Last active
May 2, 2020 19:49
-
-
Save paul42/e1ce3c905b214a1f9f83880918e3b244 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or 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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions | |
| // - XState (all XState exports) | |
| const childMachine = Machine({ | |
| id: 'child', | |
| initial: 'step1', | |
| states: { | |
| step1: { | |
| on: { STEP: 'step2'} | |
| }, | |
| step2: { | |
| on: { STEP: 'step3'} | |
| }, | |
| step3: { | |
| type: 'final' | |
| }, | |
| } | |
| }) | |
| const parentMachine = Machine({ | |
| id: 'parent', | |
| initial: 'idle', | |
| states: { | |
| idle: { | |
| on: { | |
| ACTIVATE: 'active' | |
| } | |
| }, | |
| active: { | |
| invoke: { | |
| id: 'child', | |
| src: childMachine, | |
| onDone: 'done' | |
| }, | |
| on: { | |
| STEP: { | |
| actions: send('STEP', { | |
| to: 'child' | |
| }) | |
| } | |
| } | |
| }, | |
| done: {} | |
| } | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment