I would like to be able to filter my persisted state machines to only those which have not reached a final state. i.e. no point starting a machine which has already reached its final state. Currently there doesn't appear to be a good way to do this without starting the machine.
Perhaps it could be a method on the State prototype e.g.:
const state = State.create(data)
if (state.isFinal()) {
interpret(machine).start(state)
}
However this would prevent filtering db records without instantiating State for each of them. A serialisable flag would be preferable e.g.:
if (data.isFinal) {
interpret(machine).start(data)
}
// queryable from the db level:
const datas = await db.query({ isFinal: false })
datas.forEach(data => interpret(machine).start(data))
Feature request
Originally discussed here: https://spectrum.chat/statecharts/general/detecting-state-machine-is-done~56dda5bc-8031-4840-96d7-f0458cca12d6
I would like to be able to filter my persisted state machines to only those which have not reached a final state. i.e. no point starting a machine which has already reached its final state. Currently there doesn't appear to be a good way to do this without starting the machine.
Perhaps it could be a method on the
State
prototype e.g.:However this would prevent filtering db records without instantiating
State
for each of them. A serialisable flag would be preferable e.g.: