Skip to content

Instantly share code, notes, and snippets.

@ivorpad
Last active February 27, 2020 00:32
Show Gist options
  • Save ivorpad/0cd907979d4bbaf1955da656883a287c to your computer and use it in GitHub Desktop.
Save ivorpad/0cd907979d4bbaf1955da656883a287c to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const connectedMachine = Machine({
id: 'connectedData',
initial: 'idle',
context: {
results: []
},
states: {
idle: {
on: {
ADD: 'pending',
DELETE: 'pending'
}
},
pending: {
entry: ['fetchData'],
on: {
RESOLVE: {
target: 'success',
actions: ['setResults']
},
FAIL: 'failure'
}
},
success: {
on: {
FETCH: 'pending'
}
},
failure: {
on: {
FETCH: 'pending'
}
},
}
}, {
actions: {
fetchData: () => console.log('fetching'),
setResults: () => console.log('success')
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment