Skip to content

Instantly share code, notes, and snippets.

@llldc21
Last active January 17, 2020 20:09
Show Gist options
  • Select an option

  • Save llldc21/564652e4060588a6b608865475940007 to your computer and use it in GitHub Desktop.

Select an option

Save llldc21/564652e4060588a6b608865475940007 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
initial: 'draft',
context: {
state: 'draft'
},
states: {
draft: {
on: {
READY: 'ready',
DELETED: 'deleted'
}
},
ready: {
on: {
QUEUE: 'queue',
INBOX: 'inbox'
}
},
queue: {
on: {
SEND: 'waiting'
}
},
inbox: {
on: {
CANCELED: 'canceled',
SEND: 'waiting',
DRAFT: 'draft'
}
},
waiting: {
on: {
CANCELED: 'canceled',
ACCEPTED: 'accepted',
REFUSED: 'refused'
}
},
canceled: {
on: {
DRAFT: 'draft',
},
type: 'final'
},
accepted: {
on: {
WAITING: 'waiting',
CANCELED: "canceled",
},
type: 'final'
},
refused: {
on: {
DRAFT: 'draft'
},
type: 'final'
},
deleted: {
type: 'final'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment