Last active
July 3, 2019 12:06
-
-
Save kandros/4ef4896cbe1db32d2ffd092466eeac8f to your computer and use it in GitHub Desktop.
Working Software
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 paymentMachine = Machine({ | |
id: 'payment', | |
initial: 'method', | |
states: { | |
method: { | |
initial: 'cash', | |
states: { | |
cash: { on: { SWITCH_CHECK: 'check' } }, | |
check: { on: { SWITCH_CASH: 'cash' } }, | |
hist: { type: 'history' } | |
}, | |
on: { NEXT: 'review' } | |
}, | |
review: { | |
on: { PREVIOUS: 'method.hist' } | |
} | |
} | |
}); |
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
https://hasura-demo-postgres.herokuapp.com/console/api-explorer | |
``` | |
{ | |
clients(where: {id: { | |
_eq: 1 | |
}}){ | |
name | |
} | |
} | |
``` | |
// aggregato della somma di tutti i budget per ogni cliente | |
``` | |
{ | |
clients { | |
name | |
projects_aggregate { | |
aggregate { | |
sum { | |
budget | |
} | |
} | |
} | |
} | |
} | |
``` | |
per ogni client | |
sum e average of his projects | |
``` | |
{ | |
clients { | |
name | |
projects { | |
name | |
budget | |
} | |
projects_aggregate { | |
aggregate { | |
avg { | |
budget | |
} | |
sum { | |
budget | |
} | |
} | |
} | |
} | |
} | |
``` | |
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 stepMachine = Machine({ | |
id: 'step', | |
initial: 'one', | |
states: { | |
one: { | |
on: { NEXT: 'two' } | |
}, | |
two: { | |
on: { NEXT: 'three', PREV: 'one' } | |
}, | |
three: { | |
on: { PREV: 'two' } | |
} | |
} | |
}); |
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 timeoutMachine = Machine({ | |
initial: 'idle', | |
strict: true, | |
states: { | |
idle: { | |
on: { ACTIVITY: 'idle' }, | |
after: { 3000: 'timeout' }, | |
}, | |
timeout: { | |
on: { ACTIVITY: '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 lightMachine = Machine({ | |
id: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { | |
TIMER: 'yellow' | |
} | |
}, | |
yellow: { | |
on: { | |
TIMER: 'red' | |
} | |
}, | |
red: { | |
on: { | |
TIMER: 'green' | |
} | |
} | |
} | |
}); |
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 pedestrianStates = { | |
initial: 'walk', | |
states: { | |
walk: { | |
on: { | |
PED_TIMER: 'wait' | |
} | |
}, | |
wait: { | |
on: { | |
PED_TIMER: 'stop' | |
} | |
}, | |
stop: {} | |
} | |
}; | |
const lightMachine = Machine({ | |
id: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { | |
TIMER: 'yellow' | |
} | |
}, | |
yellow: { | |
on: { | |
TIMER: 'red' | |
} | |
}, | |
red: { | |
on: { | |
TIMER: 'green' | |
}, | |
...pedestrianStates | |
} | |
} | |
}); |
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 wordMachine = Machine({ | |
id: 'word', | |
type: 'parallel', | |
states: { | |
bold: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_BOLD: 'off' } | |
}, | |
off: { | |
on: { TOGGLE_BOLD: 'on' } | |
} | |
} | |
}, | |
underline: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_UNDERLINE: 'off' } | |
}, | |
off: { | |
on: { TOGGLE_UNDERLINE: 'on' } | |
} | |
} | |
}, | |
italics: { | |
initial: 'off', | |
states: { | |
on: { | |
on: { TOGGLE_ITALICS: 'off' } | |
}, | |
off: { | |
on: { TOGGLE_ITALICS: 'on' } | |
} | |
} | |
}, | |
list: { | |
initial: 'none', | |
states: { | |
none: { | |
on: { BULLETS: 'bullets', NUMBERS: 'numbers' } | |
}, | |
bullets: { | |
on: { NONE: 'none', NUMBERS: 'numbers' } | |
}, | |
numbers: { | |
on: { BULLETS: 'bullets', NONE: 'none' } | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment