-
-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Currently, it is not possible to map a value produced by a Sub to multiple ones, which could be useful in many cases.
Here is my own use case: I am making a Scala wrapper for Pokemon Showdown's API. The messages sent by the server look like this:
>roomid
message1
message2
...
in a single text frame.
WebSocket#subscribe returns a Sub[F, WebSocketEvent] (excluding the mapping function asked in parameter) and I'd like to be able to turn this WebSocketEvent into multiple ServerMessage (from my API).
My first intuition was to use flatMap+Sub.combine but the former method does not exist and looking at the architecture of Sub, I'm not sure if it is possible to implement it cleanly.
Another approach would be to introduce a Sub[F, A]#mapMultiple (or similar name) taking a A => Iterable[B] and returning a Sub[F, B].