Last active
January 6, 2021 16:17
-
-
Save AndreAffonso/262482689ac6f4eef0f08e4934757b6c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
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
// Available variables: | |
// - Idle | |
// - loading | |
// - not found | |
// - Instructions | |
// - Step Details | |
// - Camera | |
// - Done | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
initial: 'idle', | |
context: { | |
retries: 0 | |
}, | |
states: { | |
idle: { | |
on: { | |
FETCH: 'loading' | |
} | |
}, | |
loading: { | |
on: { | |
CREATE: 'instructions', | |
CONTINUE: 'stepDetails', | |
ERROR: 'failure', | |
NOT_FOUND: 'notFound' | |
} | |
}, | |
instructions: { | |
on: { | |
START: 'stepDetails', | |
} | |
}, | |
stepDetails: { | |
on: { | |
NEXT: 'camera' | |
} | |
}, | |
camera: { | |
on: { | |
NEXT: 'stepDetails', | |
DONE: 'finished' | |
} | |
}, | |
finished: { | |
type: 'final' | |
}, | |
notFound: { | |
type: 'final' | |
}, | |
failure: { | |
on: { | |
RETRY: { | |
target: 'loading', | |
actions: assign({ | |
retries: (context, event) => context.retries + 1 | |
}) | |
} | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment