Skip to content

Instantly share code, notes, and snippets.

@njdancer
njdancer / machine.js
Last active March 2, 2021 01:17
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'categoryList',
initial: 'loading',
context: {
},
states: {
loading: {
invoke: {
src: "loadData",
@njdancer
njdancer / machine.js
Last active May 14, 2020 03:22
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@njdancer
njdancer / machine.js
Last active April 21, 2020 01:06
Generated by XState Viz: https://xstate.js.org/viz
const loadData = (callback, receive) => {
const intervalId = setInterval(() => {
callback({type:"DATA", data: "data"})
console.log("called")
}, 2500)
return () => clearInterval(intervalId)
}
const appMachine = Machine({
id: 'app',
@njdancer
njdancer / machine.js
Last active July 20, 2022 20:18
Generated by XState Viz: https://xstate.js.org/viz
const timelineMachine = Machine(
{
id: "timeline",
initial: "idle",
context: {},
on: {
"UPDATE_SPACES": {
actions: "assignSpaces"
},
"ADMINISTER": "admin"
@njdancer
njdancer / machine.js
Created March 3, 2020 04:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@njdancer
njdancer / machine.js
Created February 17, 2020 00:28
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
interface Measurements {
x: number
y: number
width: number
height: number
pageX: number
pageY: number
}
export const useMeasure: () => [RefObject<View>, Measurements] = () => {
@njdancer
njdancer / machine.js
Last active October 12, 2019 07:38
Generated by XState Viz: https://xstate.js.org/viz
const systemMachine = Machine({
id: "system",
context: {},
initial: "loading",
states: {
loading: {
id: "loadSystemData",
src: "loadSystemData",
onDone: {
target: "configure",
@njdancer
njdancer / machine.js
Last active October 10, 2019 22:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@njdancer
njdancer / machine.js
Last active October 9, 2019 05:44
Generated by XState Viz: https://xstate.js.org/viz
const requestMachine = Machine(
{
context: {
failGracefully: false,
tokenUpdated: false,
},
id: "request",
initial: "loading",
on: {
REFRESH: ".loading",