Skip to content

Instantly share code, notes, and snippets.

@Mozart409
Last active April 26, 2020 06:07
Show Gist options
  • Save Mozart409/8f8c51e1397a5904d8a690a1036f363a to your computer and use it in GitHub Desktop.
Save Mozart409/8f8c51e1397a5904d8a690a1036f363a to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const sendingMessagesMachine = Machine({
id: 'sendingMessagesMachine',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
SEARCHUSER: 'selectUser'
}
},
selectUser:{
on:{
WRITEMESSAGE:'sendMessage'
}
},
sendMessage: {
on: {
SENDMESSAGE:'sendingData',
}
},
sendingData: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: {
target: 'sendingData',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment