Skip to content

Instantly share code, notes, and snippets.

@leeovery
Last active August 26, 2020 18:40
Show Gist options
  • Save leeovery/b59449613418db1adf4187daa9f2da64 to your computer and use it in GitHub Desktop.
Save leeovery/b59449613418db1adf4187daa9f2da64 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
initial: 'ready',
context: {
retries: 0
},
states: {
ready: {
invoke: {
src: 'listenForTypingOnChannel',
},
type: 'parallel',
states: {
sending: {
entry: [
'createMessageAndPushToStack',
'clearMessageInput'
],
},
receiving: {
entry: [
'createMessageAndPushToStack',
'clearMessageInput'
],
},
},
on: {
SEND_MESSAGE: [
{
cond: 'isValidMessage',
target: '.sending'
},
],
RECEIVE_MESSAGE: [
{
cond: 'isValidMessage',
target: '.receiving'
},
],
TYPING: {
actions: 'sendTypingEvent'
},
USER_TYPING: {
actions: 'receiveTypingEvent'
}
}
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment