Skip to content

Instantly share code, notes, and snippets.

@CAWeissen
Last active February 6, 2020 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CAWeissen/3c42cbb6cd7d1e2bea346f5ee825053b to your computer and use it in GitHub Desktop.
Save CAWeissen/3c42cbb6cd7d1e2bea346f5ee825053b to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const videoMachine = Machine({
id: 'video',
initial: 'loading',
context: {
video: null,
duration: 0,
elapsed: 0
},
states: {
loading: {
on: {
FAIL: 'failure',
LOADED: {
target: 'ready',
actions: assign({
video: (context, event) => {},
duration: (context, event) => {}
})
}
}
},
ready: {
initial: 'paused',
states: {
paused: {
on: {
PLAY: {
target: 'playing',
actions: 'playVideo'
}
}
},
playing: {
on: {
PAUSE: {
target: 'paused',
actions: 'pauseVideo'
},
END: 'ended',
TIMING: {
target: 'playing',
actions: assign({
elapsed: ({video}, _event) => {}
})
}
}
},
ended: {
on: {
PLAY: {
target: 'playing',
actions: 'restartVideo'
}
}
}
}
},
failure: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment