Skip to content

Instantly share code, notes, and snippets.

@jonboiser
Last active August 24, 2020 17:22
Show Gist options
  • Save jonboiser/910f30d032babcecb8febe80e82bcfeb to your computer and use it in GitHub Desktop.
Save jonboiser/910f30d032babcecb8febe80e82bcfeb to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
// Original version
const machine =
Machine({
id: 'copymodal_original',
initial: 'SELECT_CLASSROOM',
context: {
groups: [],
},
states: {
SELECT_CLASSROOM: {
on: {
fetchgroups: 'SELECT_GROUPS',
},
},
SELECT_GROUPS: {
// Event: { type: SELECT_GROUPS, classroomId }
initial: 'LOADING',
on: {
submit: 'READY_TO_SUBMIT',
},
states: {
LOADING: {
invoke: {
src(context, event) {
return LearnerGroupResource.fetchCollection({
getParams: { parent: event.classroomId },
});
},
onDone: {
target: 'SUCCESS',
actions: assign({ groups: (context, event) => event.data }),
},
onError: {
target: 'FAILURE',
},
},
},
SUCCESS: {},
FAILURE: {},
},
},
READY_TO_SUBMIT: {
type: 'final',
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment