Last active
April 16, 2020 15:53
-
-
Save lucasmotta/9155bf12696327ce31b4538187bddf3b 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 videoMachine = Machine({ | |
id: 'video', | |
initial: 'loading', | |
context: { | |
video: undefined, | |
duration: 0, | |
elapsed: 0, | |
}, | |
states: { | |
loading: { | |
on: { | |
LOADED: { | |
target: 'ready', | |
actions: 'setVideo', | |
}, | |
FAIL: 'failure', | |
}, | |
}, | |
ready: { | |
initial: 'paused', | |
states: { | |
history: { | |
type: 'history', | |
}, | |
paused: { | |
on: { | |
PLAY: 'playing', | |
SHOW_SYNOPSIS: '#video.synopsis', | |
}, | |
}, | |
playing: { | |
initial: 'active', | |
on: { | |
TIMING: { | |
actions: 'setElapsed', | |
}, | |
PAUSE: { | |
target: 'paused', | |
}, | |
SHOW_SYNOPSIS: '#video.synopsis', | |
END: 'ended', | |
TOUCH_SCREEN: 'playing.active', | |
}, | |
states: { | |
active: { | |
after: { | |
3000: 'idle', | |
}, | |
}, | |
idle: {}, | |
}, | |
}, | |
ended: { | |
on: { | |
PLAY: { | |
target: 'playing', | |
actions: 'restartVideo', | |
}, | |
}, | |
}, | |
}, | |
}, | |
synopsis: { | |
on: { | |
HIDE_SYNOPSIS: '#video.ready.history', | |
}, | |
}, | |
failure: { | |
type: 'final', | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment