Last active
December 3, 2019 09:09
-
-
Save happylinks/eeb04a8a3f29d1fa11c382399ce78853 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
| const presentedLayersMachine = Machine({ | |
| id: 'layers', | |
| initial: 'loading', | |
| context: { | |
| scarletPreviewer: null, | |
| draftLayers: [], | |
| publishedLayers: [], | |
| presentedLayers: [], | |
| initialArtboard: null, | |
| query: () => Promise.resolve(), | |
| isFirstRender: true, | |
| }, | |
| states: { | |
| loading: { | |
| invoke: { | |
| id: 'copyArtboardQuery', | |
| src: context => context.query && context.query(), | |
| onDone: { | |
| target: 'success', | |
| }, | |
| onError: { | |
| target: 'failure', | |
| }, | |
| }, | |
| }, | |
| success: { | |
| on: { | |
| '': { | |
| target: 'idle', | |
| }, | |
| }, | |
| }, | |
| failure: { | |
| type: 'final', | |
| }, | |
| idle: { | |
| on: { | |
| DISCARD_ALL: { | |
| target: 'idle.rendering', | |
| }, | |
| DISCARD_SINGLE: { | |
| target: 'idle.rendering', | |
| }, | |
| SET_VISIBILITY: { | |
| target: 'idle.rendering', | |
| }, | |
| SET_VALUE: { | |
| target: 'idle.rendering', | |
| }, | |
| }, | |
| states: { | |
| rendering: { | |
| on: { | |
| ON_PREVIEWER_RENDERED: [ | |
| { | |
| target: 'repositioning', | |
| cond: 'hasUnpositionedLayers', | |
| }, | |
| { target: 'rendered' }, | |
| ], | |
| }, | |
| }, | |
| repositioning: { | |
| on: { | |
| ON_PREVIEWER_RENDERED: 'rendered', | |
| }, | |
| }, | |
| rendered: { | |
| entry: assign({ | |
| isFirstRender: (ctx, e) => false, | |
| }), | |
| } | |
| }, | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment