This is more of a question/feature request (or at least basis for discussion of such):
Is there any standard way to add data to a state, or would you be interested in discussing such a feature?
I think in many business cases it would be useful to attach some data to a state as opposed to creating a multitude of individual states (which not practical if there are many "sub-states").
Sadly TypeScript does not support data in enum cases, so I don't see a straightforward way yet to implement this in TypeScript/TypeState. In Swift or Rust it is a core feature to add data to enum cases, so under such circumstances no special casing would be needed.
An example of a state machine that would be more useful with added data would be:
enum AirplaneBoarding {
case Pending
case Ongoing(peopleBoarded: number)
case Finished
}
Do you have any implementation hints on how to approach something like the above? Or is this something that should not attempted when working with FSMs for some reason?
This is more of a question/feature request (or at least basis for discussion of such):
Is there any standard way to add data to a state, or would you be interested in discussing such a feature?
I think in many business cases it would be useful to attach some data to a state as opposed to creating a multitude of individual states (which not practical if there are many "sub-states").
Sadly TypeScript does not support data in enum cases, so I don't see a straightforward way yet to implement this in TypeScript/TypeState. In Swift or Rust it is a core feature to add data to enum cases, so under such circumstances no special casing would be needed.
An example of a state machine that would be more useful with added data would be:
Do you have any implementation hints on how to approach something like the above? Or is this something that should not attempted when working with FSMs for some reason?