Last active
October 31, 2019 09:38
-
-
Save tamebadger/1e9b740f1605b7753dddb1d3ed4ebcf9 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
const parentMachine = Machine({ | |
id: 'your_id_here', | |
initial: 'pending', | |
states: { | |
pending: { | |
on: { CHANGE_EVENT: 'process' } | |
}, | |
process: { | |
type: 'parallel', | |
states: { | |
fetchMachine1: { | |
initial: 'initialize', | |
states: { | |
initialize: { | |
on: { | |
'FETCH.REQUEST': { | |
target: 'pending', | |
} | |
} | |
}, | |
pending: { | |
invoke: { | |
src: 'fetch', | |
onDone: { | |
target: 'success', | |
actions: ['updateResponse'] | |
}, | |
onError: { | |
target: 'failure', | |
actions: ['updateError'] | |
} | |
}, | |
}, | |
success: { | |
entry: ['fetchSuccess'], | |
on: { | |
'FETCH.REQUEST': 'pending' | |
}, | |
type: 'final' // 'success' is a final state node for 'fetchMachine1' | |
}, | |
failure: { | |
entry: ['fetchFailure'], | |
on: { | |
'FETCH.REQUEST': 'pending' | |
} | |
} | |
} | |
}, | |
fetchMachine2: { | |
initial: 'initialize', | |
states: { | |
initialize: { | |
on: { | |
'FETCH.REQUEST': { | |
target: 'pending', | |
} | |
} | |
}, | |
pending: { | |
invoke: { | |
src: 'fetch', | |
onDone: { | |
target: 'success', | |
actions: ['updateResponse'] | |
}, | |
onError: { | |
target: 'failure', | |
actions: ['updateError'] | |
} | |
}, | |
}, | |
success: { | |
entry: ['fetchSuccess'], | |
on: { | |
'FETCH.REQUEST': 'pending' | |
}, | |
type: 'final' // 'success' is a final state node for 'fetchMachine1' | |
}, | |
failure: { | |
entry: ['fetchFailure'], | |
on: { | |
'FETCH.REQUEST': 'pending' | |
} | |
} | |
} | |
} | |
}, | |
onDone: 'pending' | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment