Skip to content

Instantly share code, notes, and snippets.

@BrunoAlmeidaKotesky
Last active March 7, 2023 14:23
Show Gist options
  • Save BrunoAlmeidaKotesky/56c29a2b547ffeda62741c0771df2aea to your computer and use it in GitHub Desktop.
Save BrunoAlmeidaKotesky/56c29a2b547ffeda62741c0771df2aea to your computer and use it in GitHub Desktop.
Proposal state machine for sp-list-formatter
function createStateMachine<States extends string, TagIds extends string>(
events: {
for: [States, TagIds, FormatterOptions][],
transitions: Array<{
from: States,
to: States,
when: {
operator: Operators,
operands: Operands
}
}>
}
) {
//Don't know how to implement that with ListFormatterBuilder yet.
for (const [state, tagId, config] of events.for) {
// ... ???
}
}
const t = createStateMachine<"A" | "D", "div1">({
for: [
["A", "div1", {}],
["D", "div1", {}]
],
transitions: [{
from: "A",
to: "D",
when: {
operator: "==",
operands: ["@currentField", "x"]
}
}]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment