Skip to content

Instantly share code, notes, and snippets.

View tomByrer's full-sized avatar
🎦
researching video players

Tom Byrer tomByrer

🎦
researching video players
View GitHub Profile
@tomByrer
tomByrer / machine.js
Created November 6, 2020 04:42
Generated by XState Viz: https://xstate.js.org/viz
const verifyChoice = Machine({
id: 'vc',
type: 'parallel',
states: {
choiceA: {
initial: 'empty',
states: {
empty: {
on: {
CLICK: 'selected',
@tomByrer
tomByrer / machine.js
Last active November 6, 2020 04:28
Generated by XState Viz: https://xstate.js.org/viz
const verifyChoice = Machine({
id: 'vc',
type: 'parallel',
states: {
choiceA: {
initial: 'empty',
states: {
empty: {
on: {
CLICK: 'selected',
// Demostrate `raise` action
const stubbornMachine = Machine({
id: 'raisedmo',
initial: 'entry',
states: {
entry: {
on: {
STEP: {
target: 'middle',
},
@tomByrer
tomByrer / machine.js
Created October 20, 2020 05:27
Generated by XState Viz: https://xstate.js.org/viz
// visulizer will not show child machine :(
const childMachine = Machine({
id: "child",
initial: "step1",
states: {
step1: {
on: { STEP: "step2" }
},
step2: {
@tomByrer
tomByrer / machine.js
Last active October 19, 2020 19:27
Generated by XState Viz: https://xstate.js.org/viz
// orig: https://xstate.js.org/viz/?gist=41fb3365af80efff10afb782e9cf9e61
const powerstrip = Machine({
id: 'powerstrip',
initial: 'powerstripOff',
states: {
powerstripOff: {
id: 'basementPowerstriphOff',
on: {
SWITCH_ON: 'poweredOn'
}
@tomByrer
tomByrer / machine.js
Last active October 19, 2020 19:27
Generated by XState Viz: https://xstate.js.org/viz
// orig: https://github.com/eggheadio/eggheadio-course-notes/blob/6a4bcc537c0aa6c301d26e0c929921c18de59ef9/introduction-to-state-machines-using-xstate/notes/15_xstate-simplify-state-explosion-in-xstate-through-hierarchical-states.md
const powerstrip = Machine({
id: 'powerstrip',
initial: 'powerstripOff',
states: {
powerstripOff: {
id: 'basementPowerstriphOff',
on: {
SWITCH_ON: 'poweredOn'
}
@tomByrer
tomByrer / machine.js
Last active October 19, 2020 12:15
Generated by XState Viz: https://xstate.js.org/viz
// source: https://egghead.io/lessons/xstate-simplify-state-explosion-in-xstate-through-hierarchical-states
const door = Machine({
id: 'door',
initial: 'locked',
states: {
locked: {
id: 'locked',
on: {
UNLOCK: 'unlocked'
}
@tomByrer
tomByrer / machine.js
Created October 19, 2020 11:07
Generated by XState Viz: https://xstate.js.org/viz
const spinnerMachine = Machine({
id: 'spinner',
initial: 'powerStripOff',
states: {
powerStripOff: {
on: {
SWITCH_ON: 'powerStripOn',
},
},
powerStripOn: {
@tomByrer
tomByrer / machine.js
Last active October 19, 2020 00:40
Generated by XState Viz: https://xstate.js.org/viz
const spinnerMachine = Machine({
id: 'spinner',
initial: 'stopped',
states: {
stopped: {
on: {
FOOT_DOWN: 'running',
},
},
running: {
@tomByrer
tomByrer / machine.js
Last active September 30, 2020 23:45
Generated by XState Viz: https://xstate.js.org/viz
const radioGroup = Machine(
{
id: "radioGroup",
initial: "emptied",
context: {
selected: "",
},
states: {
emptied: {
on: {