Last active
April 26, 2020 06:07
-
-
Save Mozart409/8f8c51e1397a5904d8a690a1036f363a 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 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