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 / 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 / ts-0-60.ts
Last active January 22, 2021 04:55
TypeScript from 0 to 60
// No TypeScript
function add(a, b) {
return a + b;
}
// Type function arguments
// vvvvvv vvvvvv
function add(a: number, b: number) {
return a + b;
}
@davidkpiano
davidkpiano / machine.js
Last active November 1, 2020 21:16
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'Dog API',
initial: 'idle',
context: {
dog: null
},
states: {
idle: {
on: {
FETCH: 'loading'
@davidkpiano
davidkpiano / SassMeister-input.scss
Last active October 26, 2020 08:38
Generated by SassMeister.com.
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
/// SCSS Specificity Calculator
///
/// Utility to calculate (and display) specificity or specificity map of any
/// valid simple/compound/complex selector.
/// @author David Khourshid
@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