Skip to content

Instantly share code, notes, and snippets.

@meetbryce
Last active June 29, 2020 11:54
Show Gist options
  • Save meetbryce/37db417750c871b0e96e1134dffdcbe8 to your computer and use it in GitHub Desktop.
Save meetbryce/37db417750c871b0e96e1134dffdcbe8 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'machine',
type: 'parallel',
states: {
order: {
initial: 'DoesNotExist',
states: {
DoesNotExist: {
on: {
MB_send_order: 'UNSENT',
}
},
UNSENT: {
on: {
immediately_processed: 'QUEUED'
}
},
QUEUED: {
on: {
mailgun_started: 'SENDING'
}
},
SENDING: {
on: {
mg_fail: 'SEND_FAILURE',
mg_success_new_order: 'SENT',
mg_success_revise_order: 'SENT',
mg_success_cancel_order: 'PENDING_CANCELLATION',
}
},
SEND_FAILURE: {
type: 'final'
},
SENT: {
on: {
MB_send_revision: 'QUEUED',
MB_send_cancel: 'QUEUED',
PUB_approves: 'ACCEPTED',
}
},
ACCEPTED: {
on: {
MB_send_revision: 'QUEUED',
MB_send_cancel: 'QUEUED',
}
},
PENDING_CANCELLATION: {
on: {
PUB_approves: 'CANCELED',
}
},
CANCELED: {
type: 'final'
}
}
},
booking: {
initial: 'UNSENT',
states: {
DELETED: {
type: 'final'
},
DRAFT: {
on: {
MB_set_not_draft: 'UNSENT',
MB_delete: 'DELETED'
}
},
UNSENT: {
on: {
MB_delete: 'DELETED',
MB_set_draft: 'DRAFT',
MB_send_order: 'SENT',
}
},
SENT: {
on: {
MB_make_changes: 'REVISED',
PUB_approves: 'ACCEPTED',
MB_send_cancel: 'CANCELED',
mg_fail: 'SEND_FAILURE',
}
},
SEND_FAILURE: {
type: 'final'
},
ACCEPTED: {
on: {
MB_make_changes: 'REVISED',
MB_send_cancel: 'CANCELED',
}
},
REVISED: {
on: {
MB_send_revision: 'SENT',
MB_send_cancel: 'CANCELED',
}
},
CANCELED: {
type: 'final'
},
},
},
is_seen_subsystem: {
initial: 'UNSENT',
states: {
UNSENT: {
on: {
mg_success: 'SENT_or_PENDING_X',
}
},
SENT_or_PENDING_X: {
on: {
PUB_opens_email: 'SEEN',
PUB_approves: 'ACCEPTED',
}
},
SEEN: {
on: {
PUB_approves: 'ACCEPTED',
}
},
ACCEPTED: {
type: 'final'
},
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment