You could probably use a combination `share` and `...
# rx
a
You could probably use a combination
share
and
buffer
to get that behavior, but I'd honestly just go the behavior subject route.
i
Hmm but that makes things more verbose. Why would I prefer it (if it's possible using those operators)?
though the behavior subject can be called with startWith(observable) or something like that, right?
a
It's an observable so you can use all of the normal operators
I think the
share
+
buffer
route (and I'm not sure that would actually work) will be more verbose and require more cognitive load to reason through
BehaviorSubject is very very simple and one line to declare, and one extra line to expose hidden.
share
+
replay
is probably what you actually want if you're going the observable route
z
share
probably doesn't make sense with
replay
, they're both multicasting operators (
share
is just
publish().refCount()
). You want just
replay(1)
and then either
refCount
,
autoConnect
, or to just call
connect
yourself on the returned
ConnectableObservable
.
👍 2
i
awesome, thanks!
t