xstate
xstate copied to clipboard
v5 - follow-up for signals
Ye, those could be perhaps handled like this - but the described problem here wouldn't totally go away with such an approach. Here, we are also handling some other, "internal", events - like snapshotEventType. This doesn't quite fit the idea of signals, it's not related to lifecycle etc.
In theory, we could wrap regular events (TEvent) in another custom event - call transition with it, handle that in the switch case, and "forward" the unpacked even in the dedicated case. This was the type of this behavior would become smth like Behavior<LifecycleEvent | typeof snapshotEventType | EventWrapper<TEvent>, StateFrom<TMachine>>.
It would help us out with the types and we wouldn't be able to end up with any namespace clashes. OTOH it feels like juggling stuff a little bit too much, OYAH programming is about juggling stuff :sweat_smile:
Originally posted by @Andarist in https://github.com/statelyai/xstate/pull/3319#discussion_r880631238