Skip to content

Instantly share code, notes, and snippets.

View 0xjcf's full-sized avatar
🏠
Working from home

JOSΞ 0xjcf

🏠
Working from home
View GitHub Profile
@0xjcf
0xjcf / trafficLightMachine.tsx
Last active October 17, 2023 14:32
Traffic Light State Machine
import { createMachine, send } from "xstate";
createMachine({
id: "traffic-light-machine",
type: "parallel",
states: {
trafficSignal: {
initial: "greenLight",
states: {
greenLight: {
@0xjcf
0xjcf / modalMachine.js
Last active September 3, 2020 18:39
Generated by XState Viz: https://xstate.js.org/viz
const modalMachine = Machine({
id: 'modal-machine',
initial: 'logIn',
states: {
logIn: {
initial: 'idle',
states: {
idle: {}
},
on: {
@0xjcf
0xjcf / doorMachine.js
Last active September 3, 2020 18:40
Generated by XState Viz: https://xstate.js.org/viz
const doorMachine = Machine({
id: 'door',
initial: 'locked',
states: {
locked: {
id: 'locked',
on: {
UNLOCKED: 'unlocked'
}
},
@0xjcf
0xjcf / LightBulbMachine.js
Last active September 3, 2020 18:36
Generated by XState Viz: https://xstate.js.org/viz
const bulbMachine = Machine(
{
id: 'lightBulb',
initial: 'unlit',
context: {
color: '#fff'
},
states: {
lit: {
on: {