Last active
August 24, 2020 17:22
-
-
Save jonboiser/910f30d032babcecb8febe80e82bcfeb 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: | |
// - 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