Last active
November 28, 2020 15:44
-
-
Save AndresRodH/d133412bfa9d9b6b57dd88a26dfae7f5 to your computer and use it in GitHub Desktop.
Example 3
This file contains hidden or 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
const doTheThingMachine = Machine({ | |
id: 'do-the-thing', | |
initial: 'validating', | |
states: { | |
validating: { | |
invoke: { | |
src: 'validateArgs', | |
onDone: 'handlingThings', | |
onError: { | |
target: 'failure', | |
actions: 'invalidArgsError' | |
} | |
} | |
}, | |
handlingThings: { | |
type: 'parallel', | |
onDone: [ | |
{target: 'success', cond: 'noErrorsHappened'}, | |
{target: 'failure', actions: 'performCleanups'}, | |
], | |
states: { | |
thingOne: { | |
initial: 'handlingA', | |
states: { | |
handlingA: { | |
invoke: { | |
src: 'handleA', | |
onDone: { | |
target: 'complete', | |
actions: 'handleASuccess', | |
}, | |
onError: { | |
target: 'complete', | |
actions: 'handleAError', | |
}, | |
}, | |
}, | |
complete: { | |
type: 'final', | |
}, | |
}, | |
}, | |
}, | |
}, | |
success: { | |
type: 'final', | |
}, | |
failure: { | |
type: 'final', | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment