Last active
December 6, 2019 11:45
-
-
Save flaviouk/d67ce7fd7a5eaa3842a3c0ff7664673f 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) | |
const editMarxentMachine = Machine({ | |
id: 'editMarxent', | |
initial: 'IDLE', | |
context: { | |
token: null, | |
error: null | |
}, | |
states: { | |
IDLE: { | |
invoke: { | |
id: 'getToken', | |
src: (context, event) => Promise.resolve({ data: 'asd' }), | |
onDone: { | |
target: 'WAIT_FOR_MARXENT_EVENTS', | |
actions: assign({ token: (context, event) => event.data }) | |
}, | |
onError: { | |
target: 'FAILURE', | |
actions: assign({ error: (context, event) => event.data }) | |
} | |
} | |
}, | |
FAILURE: { | |
type: 'final' | |
}, | |
WAIT_FOR_MARXENT_EVENTS: { | |
on: { | |
DesignSaved: 'SAVE_DESIGN', | |
BomSaved: 'SHOW_BOM' | |
} | |
}, | |
SAVE_DESIGN: { | |
invoke: { | |
id: 'patchDesign', | |
src: (context, event) => Promise.resolve({ data: 'asd' }), | |
onDone: { | |
target: 'WAIT_FOR_MARXENT_EVENTS' | |
}, | |
onError: { | |
target: 'FAILURE', | |
actions: assign({ error: (context, event) => event.data }) | |
} | |
} | |
}, | |
SHOW_BOM: { | |
on: { | |
CANCEL: 'WAIT_FOR_MARXENT_EVENTS' | |
} | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment