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
Machine({ | |
id: "lightBulbMachine", | |
initial: "unlit", | |
states: { | |
unlit: { | |
on: { | |
BREAK:'broken', | |
TOOGLE: "lit" | |
} |
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 EchoMachine = Machine({ | |
id:'echo', | |
initial:'listening', | |
states:{ | |
listening:{ | |
on:{ | |
SPEAK:{ | |
actions:send({type:'ECHO'}) | |
}, | |
ECHO:{ |
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 multiColor = Machine({ | |
id: "multiColor", | |
initial: "unlit", | |
context:{ | |
color:'#000' | |
}, | |
states: { | |
unlit: { | |
on: { | |
BREAK: "broken", |
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 VendingMachine = Machine({ | |
id:'vendingMachine', | |
initial:'idle', | |
context:{ | |
deposited:0 | |
}, | |
states:{ | |
idle:{ | |
on:{ | |
SELECT_ITEM:{ |
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 doorMachine = Machine({ | |
id:'door', | |
initial:'locked', | |
states:{ | |
locked:{ | |
id:'locked', | |
on:{ | |
unlocked:'unlocked' | |
} | |
}, |
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 spaceHeader = Machine({ | |
id:'spaceHeader', | |
initial:'poweredOff', | |
states:{ | |
poweredOff:{ | |
on:{ | |
TOOGLE_POWER:'poweredOn' | |
} | |
}, | |
poweredOn:{ |
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 spaceHeaterMachine = Machine({ | |
id: 'spaceHeater', | |
initial: 'poweredOff', | |
states: { | |
poweredOff: { | |
on: { TOGGLE_POWER: 'poweredOn.hist' } | |
}, | |
poweredOn: { | |
on: { TOGGLE_POWER: 'poweredOff' }, | |
type:'parallel', |
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 tryAgainMachine = Machine({ | |
id:'tryTryagain', | |
initial:'idle', | |
context:{ | |
tries:0 | |
}, | |
states:{ | |
idle:{ | |
on:{ TRY:'trying'} | |
}, |
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 lightMachine = Machine({ | |
id:'trafficLight', | |
initial:'red', | |
context:{ | |
rushHourMultiplier:1 | |
}, | |
on:{ | |
INC_RUSH_HOUR:{ | |
actions:['incRushHour'] | |
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 fetchAnimals = ()=>{ | |
return fetch('https://www.reddit.com/r/aww.json') | |
.then(res => res.json()) | |
.then(data => data.data.children.map(child => child.data)) | |
} | |
const cuteAnimals = Machine({ | |
id:'cuteAnimals', | |
initial:'idle', | |
context:{ |
OlderNewer