Skip to content

Instantly share code, notes, and snippets.

@EliaECoyote
Last active November 13, 2019 11:01
Show Gist options
  • Save EliaECoyote/6f1df971d4d6028ad0e1e351de7deb16 to your computer and use it in GitHub Desktop.
Save EliaECoyote/6f1df971d4d6028ad0e1e351de7deb16 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const States = {
play: 'play',
error: 'error',
idle: 'idle'
}
const Transitions = {
loginSuccessful: 'loginSuccessful',
didDisplaySharer: 'didDisplaySharer',
cancelPlayRequest:
'cancelPlayRequest',
handlePlayRequestShouldChange: 'handlePlayRequestShouldChange',
encounterBlockingError: 'encounterBlockingError',
handleGuidPropUpdate: 'handleGuidPropUpdate'
}
const playerMachine = Machine({
id: 'playerMachine',
initial: States.idle,
context: {
playRequest: null,
playing: false,
error: null
},
states: {
[States.idle]: {
on: {
[Transitions.handleGuidPropUpdate]: States.play
}
},
[States.play]: {
on: {
[Transitions.cancelPlayRequest]: States.idle,
[Transitions.didDisplaySharer]: States.play,
[Transitions.handlePlayRequestShouldChange]: States.play,
[Transitions.encounterBlockingError]: States.error,
[Transitions.handleGuidPropUpdate]: States.play
}
},
[States.error]: {
on: {
[Transitions.handleGuidPropUpdate]: States.play,
[Transitions.didDisplaySharer]: States.play,
[Transitions.loginSuccessful]:
States.play,
[Transitions.cancelPlayRequest]:
States.idle,
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment