Skip to content

Instantly share code, notes, and snippets.

@atimmer
Created August 2, 2020 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atimmer/a1ed2679033a862d80388b717b44de16 to your computer and use it in GitHub Desktop.
Save atimmer/a1ed2679033a862d80388b717b44de16 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const playerStates = {
initial: 'waiting',
states: {
waiting: {
on: {
TURN_PASSED_ON: 'playing'
}
},
playing: {
on: {
PLAYED_CARDS: 'waiting',
PASSED: 'waiting'
}
}
}
};
const roundStates = {
initial: 'dealing',
states: {
dealing: {
on: {
PLAYERS_READY: 'exchanging',
}
},
exchanging: {
on: {
PLAYERS_READY: 'playing',
}
},
playing: {
type: 'parallel',
states: {
player1: playerStates,
player2: playerStates,
player3: playerStates,
player4: playerStates,
}
}
}
};
const tichuMachine = Machine({
id: 'tichu',
'initial': 'setup',
states: {
setup: {
on: {
START: 'round',
}
},
round: {
on: { ROUND_END: 'counting' },
...roundStates
},
counting: {
}
}
});
/*
const fetchMachine = Machine({
id: 'fetch',
initial: 'idle',
context: {
retries: 0
},
states: {
idle: {
on: {
FETCH: 'loading'
}
},
loading: {
on: {
RESOLVE: 'success',
REJECT: 'failure'
}
},
success: {
type: 'final'
},
failure: {
on: {
RETRY: {
target: 'loading',
actions: assign({
retries: (context, event) => context.retries + 1
})
}
}
}
}
});*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment