Skip to content

Instantly share code, notes, and snippets.

@yazeedb
Last active July 6, 2020 22:58
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 yazeedb/ef74137886dabf52183a7619d918cb65 to your computer and use it in GitHub Desktop.
Save yazeedb/ef74137886dabf52183a7619d918cb65 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const boardMachine = Machine({
initial: 'idle',
states: {
idle: {
on: {
CHANGE_COLUMN_NAME: 'changingColumnName',
CREATE_COLUMN: 'creatingColumn',
DELETE_COLUMN: 'deletingColumn',
MOVE_COLUMN: 'movingColumn',
SET_COLUMN_LIMIT: 'settingColumnLimit',
}
},
changingColumnName: {
initial: 'saving',
onDone: 'idle',
states: {
saving: {
invoke: {
src: 'changeColumnName',
onDone: {
target: 'success',
actions: 'setColumns'
},
onError: {
target: 'failure',
actions: 'flashError'
}
}
},
success: { type: 'final' },
failure: { type: 'final' }
}
},
creatingColumn: {
initial: 'saving',
onDone: 'idle',
states: {
saving: {
invoke: {
src: 'createColumn',
onDone: {
target: 'success',
actions: 'setColumns'
},
onError: {
target: 'failure',
actions: 'flashError'
}
}
},
success: { type: 'final' },
failure: { type: 'final' }
}
},
deletingColumn: {
initial: 'saving',
onDone: 'idle',
states: {
saving: {
invoke: {
src: 'deleteColumn',
onDone: {
target: 'success',
actions: 'setColumns'
},
onError: {
target: 'failure',
actions: 'flashError'
}
}
},
success: { type: 'final' },
failure: { type: 'final' }
}
},
movingColumn: {
initial: 'saving',
onDone: 'idle',
states: {
saving: {
invoke: {
src: 'moveColumn',
onDone: {
target: 'success',
actions: 'setColumns'
},
onError: {
target: 'failure',
actions: 'flashError'
}
}
},
success: { type: 'final' },
failure: { type: 'final' }
}
},
settingColumnLimit: {
initial: 'saving',
onDone: 'idle',
states: {
saving: {
invoke: {
src: 'setColumnLimit',
onDone: {
target: 'success',
actions: 'setColumns'
},
onError: {
target: 'failure',
actions: 'flashError'
}
}
},
success: { type: 'final' },
failure: { type: 'final' }
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment