-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Enforce/describe State Meta Data with TS #809
Comments
any movement on this? |
It would be nice to have this 👍 ! |
I have a use case where the UI elements and the states of my physical devices in my automated home is driven by the metadata of the states of an xstate machine. So I use metadata extensively. Being able to enforce the type of the meta property would really improve my workflow! |
Thanks for sharing the use-case! I have some ideas around typing this and other properties that I will share soon in https://github.com/statelyai/rfcs |
@nstadigs do u need for all states to have the same type of metadata or would you like for it to be per-state information? |
@Andarist having all states share the type of metadata would suit my use case best :) |
Bug or feature request?
Feature
Description:
Currently metadata is of any/unknown type but in the case of actors, I need to be able to lock down what kind of metadata each event can or should have. I'm not sure if this is wading too much into context (extended state) territory but if states can be configured to only accept certain events, they should also be able to emit only a certain type of metadata.
(Feature) Potential implementation:
This is what the API might look like
It shouldn't be a breaking change as omitting the meta definition should just imply meta can be
any
.Leaving the flexibility in makes the definition a bit verbose (maybe I don't care what the nested states have as metadata but if I decide to put it in, I'd still like some intellisense).
Would be nice if you could define a meta inside the
states
definition so that all nested states inherit the meta definition. But would that also apply to the nested states within (might break builtin states like onDone)?Link to reproduction or proof-of-concept:
Sorry, not sure how to implement this
The text was updated successfully, but these errors were encountered: