Last active
December 6, 2019 16:42
-
-
Save flaviouk/dbe449df5a953ed2d66fdc9fa01c6575 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
Machine({ | |
id: 'marxent', | |
initial: 'PENDING', | |
context: { | |
token: null, | |
error: null, | |
}, | |
states: { | |
PENDING: { | |
on: { | |
GET_TOKEN: 'GET_TOKEN', | |
}, | |
}, | |
FAILURE: { | |
type: 'final', | |
}, | |
GET_TOKEN: { | |
invoke: { | |
id: 'getDesignToken', | |
src: (_context, event) => Promise.resolve(event), | |
onDone: { | |
target: 'INITIALISE_JS_COMMUNICATOR', | |
actions: assign({ | |
token: (_context, event) => event.data.token, | |
vendorId: (_context, event) => event.data.vendorId, | |
}), | |
}, | |
onError: { | |
target: 'FAILURE', | |
actions: assign({ error: (_context, event) => event.data }), | |
}, | |
}, | |
}, | |
INITIALISE_JS_COMMUNICATOR: { | |
on: { | |
SUCCESS: 'WAIT_FOR_EVENTS', | |
FAILURE: 'FAILURE', | |
}, | |
}, | |
WAIT_FOR_EVENTS: { | |
on: { | |
DesignCreated: 'OPEN_CREATE_DESIGN_NAME_MODAL', | |
DesignSaved: 'EDIT_DESIGN', | |
BomSaved: 'OPEN_BOM_MODAL', | |
}, | |
}, | |
OPEN_CREATE_DESIGN_NAME_MODAL: { | |
on: { | |
SUCCESS: 'CREATE_DESIGN', | |
FAILURE: 'FAILURE', | |
CANCEL: 'WAIT_FOR_EVENTS', | |
}, | |
}, | |
OPEN_BOM_MODAL: { | |
on: { | |
CANCEL: 'WAIT_FOR_EVENTS', | |
}, | |
}, | |
CREATE_DESIGN: { | |
invoke: { | |
id: 'postDesign', | |
src: (context, event) => Promise.resolve({ data: 'asd' }), | |
onDone: { | |
target: 'WAIT_FOR_EVENTS', | |
}, | |
onError: { | |
target: 'FAILURE', | |
actions: assign({ error: (context, event) => event.data }), | |
}, | |
}, | |
}, | |
EDIT_DESIGN: { | |
invoke: { | |
id: 'patchDesign', | |
src: (context, event) => Promise.resolve({ data: 'asd' }), | |
onDone: { | |
target: 'WAIT_FOR_EVENTS', | |
}, | |
onError: { | |
target: 'FAILURE', | |
actions: assign({ error: (context, event) => event.data }), | |
}, | |
}, | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment