You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea of withPubSub is to extend a given behavior with the ability to publish event. Most importantly, the type for published events should be different from the type for received event, because an actor does not have to only publish events it can receive.
The current generics make it rather awkward to type the publishable events. As soon as the generic P gets defined, a user has to also provide types for the other generics. When defaults are used for the remainder, the wrapped behavior does not correctly infer its types from the given behavior.
To avoid this, a user currently has to type the published events like this: withPubSub((pub: Publish<Event>) => behavior).
Ideally, this should work: withPubSub<Event>((pub) => behavior) and should correctly infer the receive-able events and state from behavior.
I tried this, but it does not work as the resulting behavior will be typed as Behavior<any, any>:
The idea of
withPubSub
is to extend a given behavior with the ability to publish event. Most importantly, the type for published events should be different from the type for received event, because an actor does not have to only publish events it can receive.The current generics make it rather awkward to type the publishable events. As soon as the generic
P
gets defined, a user has to also provide types for the other generics. When defaults are used for the remainder, the wrapped behavior does not correctly infer its types from the given behavior.To avoid this, a user currently has to type the published events like this:
withPubSub((pub: Publish<Event>) => behavior)
.Ideally, this should work:
withPubSub<Event>((pub) => behavior)
and should correctly infer the receive-able events and state frombehavior
.I tried this, but it does not work as the resulting behavior will be typed as
Behavior<any, any>
:The text was updated successfully, but these errors were encountered: