Last active
September 29, 2019 16:19
-
-
Save jjenzz/def73de387567a95709c5c83bafa67ec 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 dismissReasonMachine = Machine({ | |
id: 'dismissReasonMachine', | |
initial: 'load', | |
context: { | |
actions: [], | |
reason: undefined, | |
action: undefined, | |
}, | |
states: { | |
load: { | |
invoke: { | |
id: 'onLoad', | |
src: 'onLoad', | |
onDone: [ | |
{ | |
cond: 'hasActions', | |
target: 'input', | |
actions: ['setActions'], | |
}, | |
{ | |
target: 'error.emptyActions' | |
} | |
], | |
onError: 'error.serverError', | |
}, | |
on: { | |
CANCEL: 'close', | |
}, | |
}, | |
input: { | |
on: { | |
SELECT_ACTION: { | |
actions: ['setAction'], | |
}, | |
ENTER_REASON: { | |
actions: ['setReason'] | |
}, | |
CANCEL: 'close', | |
SUBMIT: 'save', | |
} | |
}, | |
save: { | |
invoke: { | |
id: 'onSave', | |
src: 'onSave', | |
onDone: 'success', | |
onError: 'error.saveFailed' | |
}, | |
}, | |
success: { | |
on: { | |
TIMER: 'close', | |
}, | |
}, | |
error: { | |
states: { | |
emptyActions: {}, | |
serverError: {}, | |
saveFailed: {}, | |
} | |
}, | |
close: { | |
type: 'final', | |
} | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment