Skip to content

Instantly share code, notes, and snippets.

@fastestOrange
Last active May 21, 2021 20:00
Show Gist options
  • Save fastestOrange/485c61671446d335ad03c5e79c7d744c to your computer and use it in GitHub Desktop.
Save fastestOrange/485c61671446d335ad03c5e79c7d744c to your computer and use it in GitHub Desktop.
const whatMachine = Machine({
id: 'whatDoIDo?',
initial: 'loading',
context: {
retries: 0
},
states: {
loading: {
on: {
SUCCESS: "loaded",
FAILURE: "error"
}
},
loaded: {
on: {
PUBLISHED: "published",
DRAFT: "draft"
}
},
changes: {
on: {
// ACCEPT to which state should the state machine transaction to when this trigger is triggered.
// CLOSE to which state should the state machine transaction to when this trigger is triggered.
// RESET to which state should the state machine transaction to when this trigger is triggered.
}
},
editing: {
on: {
CHANGES: "changes",
SAVE: "draft"
}
},
draft: {
on: {
EDIT: "editing"
// WHAT OTHER TRIGGERS TO STATES GO HERE ??
}
},
published: {
on: {
EDIT: "editing",
DRAFT: "draft",
CHANGES: "changes"
}
},
error: {
// How can the this retry if there's and error
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment