Skip to content

Instantly share code, notes, and snippets.

@pangratz
Last active March 11, 2020 21:16
Show Gist options
  • Save pangratz/14be067ab91bda1fb488cbfc89753030 to your computer and use it in GitHub Desktop.
Save pangratz/14be067ab91bda1fb488cbfc89753030 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 gradesMachine = Machine({
id: 'grades',
initial: 'show_grades',
context: {
},
states: {
show_grades: {
type: "parallel",
states: {
sidebar: {
initial: "open",
states: {
open: {
initial: "tree",
on: {
CLOSE: "closed"
},
states: {
tree: {
on: {
SHOW_FILTER: "filtering"
}
},
filtering: {
on: {
SHOW_TREE: "tree"
}
}
}
},
closed: {
on: {
OPEN: "open"
}
}
}
},
table: {
initial: "showing",
states: {
showing: {
initial: "idle",
on: {
CREATE_GREADE: "create_grade",
EDIT_GRADE: "edit_grade"
},
states: {
idle: {
on: {
SELECTED: "selected",
EDIT_GRADE: "idle"
}
},
selected: {
on: {
NO_SELECTION: "idle",
}
},
hist: {
type: "history"
}
}
},
create_grade: {
initial: "idle",
on: {
GENERATE: "showing.hist",
GENERATE_AND_EDIT: "edit_grade",
DISMISS: "showing.hist"
},
states: {
idle: {
on: {
GENERATE: "idle",
GENERATE_AND_EDIT: "idle",
EDITED: "edited"
}
},
edited: {}
}
},
edit_grade: {
initial: "idle",
onDone: "showing.hist",
states: {
idle: {
on: {
CLOSE: "close",
EDITED: "edited"
}
},
edited: {
on: {
CLOSE: "close",
SAVE: "saving"
}
},
saving: {
on: {
SAVED: "close",
ERROR: "edited"
}
},
close: {
type: "final"
}
}
}
}
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment