Skip to content

Instantly share code, notes, and snippets.

@wighawag
Last active June 22, 2020 22:32
Show Gist options
  • Save wighawag/7cbe416870e9d0fd1d9bc6808605d957 to your computer and use it in GitHub Desktop.
Save wighawag/7cbe416870e9d0fd1d9bc6808605d957 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'planet',
initial: 'idle',
context: {
error: undefined
},
on: {
PROBE: {
target: '.probing',
in: 'idle',
actions: 'reset_error',
},
CANCEL: {
target: '.idle',
in: 'probing',
},
ACKNOWLEDGE_ERROR: {
target: '',
actions: 'reset_error',
cond: 'has_error',
}
},
states: {
idle: {},
probing: {
on:{
FOUND: 'found',
NOT_FOUND: 'notFound',
ERROR: {
target: 'idle',
actions: 'error_probing'
}
},
},
found: {
type: 'final',
},
notFound: {
type: 'final',
},
}
},
{
guards: {
has_error: (context) => context.error !== undefined,
},
actions: {
error_probing: assign({
error: 'error probing',
}),
reset_error: assign({
error: undefined,
}),
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment