Created
February 23, 2022 16:05
-
-
Save bowheart/437421f52d6667f5c2362949d4c368c4 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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 isAggressor = (context, event) => {} | |
const isNotAggressor = (context, event) => {} | |
const proposalMachine = Machine({ | |
id: 'proposal', | |
initial: 'waiting', | |
states: { | |
waiting: { | |
on: { | |
STATUS_NEGOTIATING: 'negotiating' | |
} | |
}, | |
negotiating: { | |
on: { | |
STATUS_CONFIRMING: [ | |
{ | |
target: 'aggressorConfirming', | |
cond: isAggressor | |
}, | |
{ | |
target: 'nonAggressorConfirming', | |
cond: isNotAggressor | |
} | |
] | |
} | |
}, | |
aggressorConfirming: { | |
on: { | |
AGGRESSOR_CHANGE: 'nonAggressorConfirming', | |
STATUS_NEGOTIATING: 'negotiating', | |
STATUS_TRADED: 'traded' | |
} | |
}, | |
nonAggressorConfirming: { | |
on: { | |
AGGRESSOR_CHANGE: 'aggressorConfirming', | |
RETURN_TO_NEGOTIATION: 'confirmingAndNegotiating', | |
STATUS_NEGOTIATING: 'negotiating', | |
STATUS_TRADED: 'traded' | |
} | |
}, | |
confirmingAndNegotiating: { | |
on: { | |
AGGRESSOR_CHANGE: 'aggressorConfirming', | |
RETURN_TO_LAST_LOOK: 'nonAggressorConfirming', | |
STATUS_NEGOTIATING: 'negotiating' | |
} | |
}, | |
traded: { | |
type: 'final' | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment