Created
August 2, 2020 19:30
-
-
Save atimmer/a1ed2679033a862d80388b717b44de16 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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