Skip to content

Instantly share code, notes, and snippets.

function timer(interval, msg) {
setInterval(() => console.log(msg), interval);
}
const initializerService = interpret(
new Machine({
initial: 'idle',
states: {
idle: {
on: {
@jeremy-green
jeremy-green / machine.js
Created September 17, 2019 21:57
Generated by XState Viz: https://xstate.js.org/viz
new Machine({
id: 'initializer',
initial: 'idle',
context: {},
states: {
idle: {
on: {
'': 'getToken',
},
},
@jeremy-green
jeremy-green / machine.js
Last active September 13, 2019 22:20
Generated by XState Viz: https://xstate.js.org/viz
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'] },
@jeremy-green
jeremy-green / machine.js
Created September 13, 2019 16:35
Generated by XState Viz: https://xstate.js.org/viz
new Machine({
id: `switch`,
initial: 'on',
context: {},
states: {
on: {
on: {
TOGGLE: 'off',
},
},
@jeremy-green
jeremy-green / machine.js
Created September 13, 2019 16:25
Generated by XState Viz: https://xstate.js.org/viz
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!!!')],
@jeremy-green
jeremy-green / machine.js
Created September 13, 2019 16:06
Generated by XState Viz: https://xstate.js.org/viz
new Machine({
id: 'wink-initializer',
initial: 'idle',
context: {},
states: {
idle: {
on: {
'': 'bootstrap',
},
},
@jeremy-green
jeremy-green / machine.js
Created September 13, 2019 12:05
Generated by XState Viz: https://xstate.js.org/viz
new Machine({
id: 'ABCDE1234567',
type: 'parallel',
context: {
battery: null,
},
states: {
status: {
id: `status-ABCDE1234567`,
initial: 'idle',
@jeremy-green
jeremy-green / machine.js
Created September 13, 2019 11:51
Generated by XState Viz: https://xstate.js.org/viz
const interval = 5000;
new Machine({
id: 'timer',
initial: 'waiting',
states: {
waiting: {
after: {
[interval]: 'loading',
},
@jeremy-green
jeremy-green / snippets.cson
Created November 13, 2018 19:25
Atom Snippets
'.source.js':
'console.log':
'prefix': 'cl'
'body': 'console.log(${2:\'${1:HERE}\'}$3);$4'
@jeremy-green
jeremy-green / snippets.cson
Created November 13, 2018 19:25
Atom Snippets
'.source.js':
'console.log':
'prefix': 'cl'
'body': 'console.log(${2:\'${1:HERE}\'}$3);$4'