Skip to content

Instantly share code, notes, and snippets.

@austinsamsel
Last active October 5, 2021 17:10
Show Gist options
  • Save austinsamsel/75739953ea168f49654430fc4652eb19 to your computer and use it in GitHub Desktop.
Save austinsamsel/75739953ea168f49654430fc4652eb19 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 FS = {
LOADING: 'LOADING',
P2P_DISABLED: 'P2P_DISABLED',
SOLD_OUT: 'SOLD_OUT',
NO_SELECTION: 'NO_SELECTION',
NOT_AUTHED: 'NOT_AUTHED',
CAN_BUY: 'CAN_BUY',
};
const EVENTS = {
UPDATE: 'UPDATE',
}
const definition = {
id: 'listing-buy-button-presenter',
initial: FS.LOADING,
context: {
FS,
EVENTS,
isAuthed: undefined,
nftListings: undefined,
selectedNFT: undefined,
},
states: {
[FS.LOADING]: {
always: [
{
target: FS.P2P_DISABLED,
cond: 'isP2PDisabled',
},
{
target: FS.SOLD_OUT,
cond: 'isSoldOut',
},
{
target: FS.NO_SELECTION,
cond: 'isNoSelection',
},
{
target: FS.NOT_AUTHED,
cond: 'isNotAuthed',
},
{
target: FS.CAN_BUY,
},
],
},
[FS.P2P_DISABLED]: {},
[FS.SOLD_OUT]: {},
[FS.NO_SELECTION]: {},
[FS.NOT_AUTHED]: {},
[FS.CAN_BUY]: {},
},
on: {
[EVENTS.UPDATE]: {
target: FS.LOADING,
actions: 'assignContext',
},
},
};
const services = {};
const guards = {
isP2PDisabled: () => false,
isSoldOut: () => false,
isNoSelection: () => false,
isNotAuthed: () => false,
};
Machine(definition, {
actions,
services,
guards,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment