For the double subscription. In case of v2 second subscription would receive same elements of just sequence as the first?
Teiva Harsanyi
@teivah
well, to be discussed maybe but in RxJava for example if you create an observable from an array, the second subscription is going to receive the same elements as the first one
here we just lose the messages as it is sent in a channel and retrieved during the first subscription
(and there's no way to retry it for the time being)
_
Artur Krysiak
@venth
If we will create function create that would receive function as argument then we could overcome the channel issue
this function would get emitter as the argument and will be responsible for emitting sequence elements
Teiva Harsanyi
@teivah
you mean as an end-user or as a maintainer of RxGo?
Artur Krysiak
@venth
Either. Such a function ease implementation of plenty of operators
Like empty - just emit complete
Teiva Harsanyi
@teivah
yes agreed
Artur Krysiak
@venth
error emit error
abd so forth
Teiva Harsanyi
@teivah
but I'm just pointing out that the current behavior is not similar to what we have in the other Rx implementations
Artur Krysiak
@venth
That’s right. Current behavior doesn’t comply to other implementations
Teiva Harsanyi
@teivah
I know the philosophy is to be based as most as possible on Idiomatic Go code
yet, for this very use-case I don't really get why we should have something different in RxGo
just my opinion obviously
Artur Krysiak
@venth
I come along with you.
Teiva Harsanyi
@teivah
and obviously, if we change that in the v2, it has to be highlighted to make sure end-users understand that the behavior is different
Artur Krysiak
@venth
+1
Teiva Harsanyi
@teivah
We need to start thinking about how to handle hot observable: values are emitted regardless whether there is an actual subscription, multicasting (one item caught by several observer)
we need something to manage a kind of publish/subscribe
either by implementing something from scratch, or reusing a proven library for such use case
has anyone an idea about something which already exists for this?
Artur Krysiak
@venth
Hot observable can be implemented as follows: get create operator, pass closure with an emitter and subscription as arguments. If subscription is active (anything subscribed) use next, error etc. otherwise just pull an element and forget. Nothing is blocking. Hot source is working
I’m not sure about multicasting. Did you mean fan-out scenario or fan-in?
Teiva Harsanyi
@teivah
fan-out
mmh, in your implementation, each call to next for example should be done in another goroutine in case where we have two subscriptions for example
otherwise the first observer would block the second one