Skip to content

Instantly share code, notes, and snippets.

@YouMinTW
Created October 4, 2021 16:53
Show Gist options
  • Save YouMinTW/f033d253321c79321b19f442912cebf9 to your computer and use it in GitHub Desktop.
Save YouMinTW/f033d253321c79321b19f442912cebf9 to your computer and use it in GitHub Desktop.
news version-1
import { createMachine } from 'xstate';
const machineConfig = {
id: 'news-version-1',
initial: "draft",
states: {
draft: {
on: {
REVIEW: {
target: "reviewing",
},
},
},
reviewing: {
on: {
REJECT: {
target: "draft",
},
APPROVE: {
target: "approved",
},
},
},
approved: {
on: {
REJECT: {
target: "draft",
},
PUBLISH: {
target: "published",
},
},
},
published: {},
},
};
const machine = createMachine(machineConfig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment