Skip to content

Instantly share code, notes, and snippets.

View davidkpiano's full-sized avatar
🎹
Working on XState Dev Tools

David Khourshid davidkpiano

🎹
Working on XState Dev Tools
View GitHub Profile
@davidkpiano
davidkpiano / poc.js
Last active October 2, 2021 12:55
xstate query ideas
function Example() {
const [{ isLoading, error, data }] = useMachine(
createQuery('repoData', () => fetch('...').then((res) => res.json()))
);
}
const machine = Machine({
id: 'ATM',
initial: 'idle',
states: {
idle: {
on: {
INSERT_CARD: 'authenticating',
}
},
authenticating: {
@davidkpiano
davidkpiano / machine.js
Created March 28, 2021 16:20
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@davidkpiano
davidkpiano / machine.js
Created October 12, 2020 15:25
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'donut',
initial: 'ingredients',
states: {
ingredients: {
on: {
NEXT: 'directions',
},
},
directions: {
@davidkpiano
davidkpiano / machine.js
Created August 31, 2020 15:29
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@davidkpiano
davidkpiano / machine.js
Created August 28, 2020 10:33
Generated by XState Viz: https://xstate.js.org/viz
const auth = Machine({
id: 'auth',
initial: 'authenticating',
states: {
authenticating: {
after: {
1000: 'authenticated'
}
},
@davidkpiano
davidkpiano / machine.js
Last active August 26, 2020 15:13
Generated by XState Viz: https://xstate.js.org/viz
const pongMachine = Machine({
initial: 'waiting',
states: {
waiting: {
on: {
PING: {
actions: sendParent('PONG', { delay: 1000 })
}
}
}
@davidkpiano
davidkpiano / machine.js
Created August 7, 2020 03:33
Generated by XState Viz: https://xstate.js.org/viz
const A1 = () => console.log('Action A1');
const machine = Machine({
initial: 's1',
states: {
h: { type: 'history' },
s1: {on: {E11: 's2'}},
s2: {on: {E11: 's3'}},
s3: {on: {E11: 's4'}},
s4: {/* ... */}
@davidkpiano
davidkpiano / machine.js
Created August 4, 2020 15:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
Machine({
id: 'planet',
initial: 'unknown',
states: {
unknown: {
on: {
PROBE: 'probing',
},
},
probing: {