Skip to content

Instantly share code, notes, and snippets.

View robertpenner's full-sized avatar

Robert Penner robertpenner

View GitHub Profile
@robertpenner
robertpenner / machine.js
Last active August 9, 2021 22:05
Generated by XState Viz: https://xstate.js.org/viz
const randomRange = (min, max) =>
min + Math.random() * (max - min);
const machine = Machine(
{
id: "Round as Individual Player",
type: "parallel",
states: {
"Player 1": {
id: "P1",
@robertpenner
robertpenner / machine.js
Last active August 6, 2021 22:40
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: "A Round - Team of 2 - By Hole",
type: "parallel",
states: {
"Player 1": {
id: "P1",
initial: "waiting",
states: {
waiting: {
on: { "START ROUND": "hole 1" },
@robertpenner
robertpenner / machine.js
Last active August 6, 2021 21:13
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: "A Pro-Am Round - Team of 2",
type: "parallel",
states: {
"Player 1 - Amateur": {
id: "P1",
type: "parallel",
states: {
hole: {
initial: "none",
const machine = Machine({
id: "A Round for a Pro-Am Pair",
type: "parallel",
states: {
"Player 1 (Amateur)": {
id: "P1",
// onDone:
initial: "waiting",
states: {
waiting: {
@robertpenner
robertpenner / machine.js
Last active August 6, 2021 18:42
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: "Tuesday - Round 1",
initial: "playing",
states: {
playing: {
onDone: 'complete',
type: "parallel",
states: {
"course 1": {
@robertpenner
robertpenner / machine.js
Last active August 6, 2021 00:58
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'Tournament events during',
initial: 'Practice',
states: {
'Practice': {
initial: 'round 1',
states: {
'round 1': {
initial: 'playing',
states: {
// Copied from:
// https://xstate-catalogue.com/machines/debounce
const fetchMachine = Machine({
id: 'debounce',
initial: 'idle',
states: {
idle: {
on: {
GO: {
actions: 'assignActionToContext',
@robertpenner
robertpenner / machine.js
Last active August 5, 2021 20:42
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'Tournament',
initial: 'inactive',
states: {
inactive: {
on: { 'SCHEDULE TOURNAMENT': 'pre' },
},
pre: {
on: { 'START TOURNAMENT': 'during' },
},
@robertpenner
robertpenner / machine.js
Last active August 10, 2021 21:30
Generated by XState Viz: https://xstate.js.org/viz
/*
TODO:
- LIVE status
- Pre and Post statuses
x delay notice (in context)
x switch category, e.g. Pro-Am
x loading data
x update data
x change sort direction
x change sort column
const context = {
// TODO: separate machines for logged in/logged out
// logged out
email: '',
password: '',
passwordA: '',
passwordB: '',
username: '',
loginError: '',