I'm an RX newbie trying to construct something that seems complex to me.
Here's the problem: I have a hot observable that is producing key-value pairs, let's say <int, foo>. They're coming in no particular order. The output should be an observable for each distinct key in the source observable. So, for each value in the source, the result should be: a new observable if the key has not been seen yet, with the new observable immediately producing the corresponding value. If the key has been seen before, the corresponding value should be produced by the corresponding observable that already exists. So:
<1, foo>-<2, foo>-<2, foo>-<1, foo>-<3, foo>-<4, foo>-<1, foo>-<3, foo>x
Output:
<1, foo>-------------------<1, foo>-------------------<1, foo>---------x
---------<2, foo>-<2,foo>----------------------------------------------x
------------------------------------<3, foo>-------------------<3, foo>x
---------------------------------------------<4, foo>------------------x
I'm attempting this with window, but am stuck on how to "detect" that a key has already been seen and then "route" the value to the existing observable.
Thanks!