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
function timer(interval, msg) { | |
setInterval(() => console.log(msg), interval); | |
} | |
const initializerService = interpret( | |
new Machine({ | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { |
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
new Machine({ | |
id: 'initializer', | |
initial: 'idle', | |
context: {}, | |
states: { | |
idle: { | |
on: { | |
'': 'getToken', | |
}, | |
}, |
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
new Machine( | |
{ | |
id: 'weather', | |
initial: 'boot', | |
states: { | |
boot: { | |
on: { | |
PRECIPITATION: { target: 'precipitation', actions: ['notify'] }, | |
NO_PRECIPITATION: { target: 'no_precipitation', actions: ['notify'] }, | |
REJECTED: { target: 'boot', actions: ['rejected'] }, |
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
new Machine({ | |
id: `switch`, | |
initial: 'on', | |
context: {}, | |
states: { | |
on: { | |
on: { | |
TOGGLE: 'off', | |
}, | |
}, |
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
new Machine({ | |
id: 'wink-bootstrapper', | |
initial: 'bootstrap', | |
states: { | |
bootstrap: { | |
invoke: { | |
src: () => Promise.all([new Promise(r => setTimeout(r, 1500)), new Promise(r => setTimeout(r, 2500)), new Promise(r => setTimeout(r, 500))]), | |
onDone: { | |
target: 'ready', | |
actions: [() => console.log('ready!!!')], |
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
new Machine({ | |
id: 'wink-initializer', | |
initial: 'idle', | |
context: {}, | |
states: { | |
idle: { | |
on: { | |
'': 'bootstrap', | |
}, | |
}, |
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
new Machine({ | |
id: 'ABCDE1234567', | |
type: 'parallel', | |
context: { | |
battery: null, | |
}, | |
states: { | |
status: { | |
id: `status-ABCDE1234567`, | |
initial: 'idle', |
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 interval = 5000; | |
new Machine({ | |
id: 'timer', | |
initial: 'waiting', | |
states: { | |
waiting: { | |
after: { | |
[interval]: 'loading', | |
}, |
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
'.source.js': | |
'console.log': | |
'prefix': 'cl' | |
'body': 'console.log(${2:\'${1:HERE}\'}$3);$4' |
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
'.source.js': | |
'console.log': | |
'prefix': 'cl' | |
'body': 'console.log(${2:\'${1:HERE}\'}$3);$4' |
NewerOlder