Skip to content

Instantly share code, notes, and snippets.

@domkm
Last active April 14, 2020 16:55
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 domkm/7234b3fe345b197db56262e33a0de3b7 to your computer and use it in GitHub Desktop.
Save domkm/7234b3fe345b197db56262e33a0de3b7 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 User = {
initial: 'user_invited_to_beacon',
states: {
user_invited_to_beacon: {
on: { accept_invitation_to_beacon: "user_active" }
},
user_active: {
on: { deactivate_user: "user_deactivated" }
},
user_deactivated: {
on: {activate_user: "user_active"}
}
}
}
const UserDutyStatus = {
initial: "user_on_duty",
states: {
user_on_duty: {
on: { mark_off_duty: "user_off_duty" }
},
user_off_duty: {
on: {mark_on_duty: "user_on_duty"}
}
}
}
const Organization = {
initial: "organization_active",
states: {
organization_active: {
on: { deactivate_organization: "organization_deactivated" }
},
organization_deactivated: {
on: {activate_organization: "organization_active"}
}
}
}
const OrganizationMembership = {
initial: 'user_invited_to_organization',
states: {
user_invited_to_organization: {
on: {accept_invitation_to_organization: "active_organization_membership" }
},
active_organization_membership: {
on: { deactivate_organization_membership: "deactivated_organization_membership" }
},
deactivated_organization_membership: {
on: {activate_organization_membership: "active_organization_membership"}
}
}
}
const CaseMembership = {
initial: 'user_invited_to_case',
states: {
user_invited_to_case: {
on: {accept_invitation_to_case: "active_case_membership" }
},
active_case_membership: {
on: { deactivate_case_membership: "deactivated_case_membership",
user_leaves_case: "deactivated_case_membership"}
},
deactivated_case_membership: {
on: {activate_case_membership: "active_case_membership"}
}
}
}
//// aircraft positioning
// out_of_the_gate
// off_the_ground
// on_the_ground
// in_the_gate
// parked - makes it unservicable
//// aircraft maintanance
// serviceable - ready to collect revenue
// unserviceable -
// - scheduled_maintenance
// - unscheduled_maintenance
// - parked
const beaconMachine = Machine({
id: 'Beacon',
type: 'parallel',
states: {
User,
UserDutyStatus,
Organization,
OrganizationMembership,
CaseMembership,
}
});
// const boldState = wordMachine.transition('bold.off', 'TOGGLE_BOLD').value;
// {
// bold: 'on',
// italics: 'off',
// underline: 'off',
// list: 'none'
// }
// const nextState = wordMachine.transition(
// {
// bold: 'off',
// italics: 'off',
// underline: 'on',
// list: 'bullets'
// },
// 'TOGGLE_ITALICS'
// ).value;
// {
// bold: 'off',
// italics: 'on',
// underline: 'on',
// list: 'bullets'
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment