Skip to content

Instantly share code, notes, and snippets.

@pke
pke / machine.js
Last active August 24, 2021 09:02
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Last active June 8, 2021 17:03
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Last active April 1, 2021 21:27
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Created April 1, 2021 00:15
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Created March 24, 2021 23:06
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Created March 11, 2021 14:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Created March 9, 2021 10:26
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@pke
pke / machine.js
Last active December 15, 2020 17:10
Generated by XState Viz: https://xstate.js.org/viz
const guards = {
canCountDown: context => !guards.countedDown(context),
countedDown: context => context.count === 0
}
const countdownMachine = Machine({
id: "countdown",
initial: "idle",
context: {
count: 10
@pke
pke / machine.js
Created December 15, 2020 09:54
Generated by XState Viz: https://xstate.js.org/viz
const HEAT_CAPACITY_OF_WATER = 4180
const heatingDuration = ({
power,
efficiency,
amount,
waterTemp,
targetTemp = 100
}) => {
const effectivePower = power * (efficiency * 0.01)
@pke
pke / machine.js
Last active January 31, 2020 00:51
Generated by XState Viz: https://xstate.js.org/viz
const setStatus = assign((context, event, meta) => ({
statusCode: meta.statusCode,
statusText: meta.statusText,
}))
const fetchMachine = Machine({
id: 'http-request',
initial: 'start',
context: {
request: {