Hey, I'm trying to write an extension method that ...
# rx
s
Hey, I'm trying to write an extension method that uses .replay internally. My problem is that if I don't follow .replay with autoConnect/refCount etc, and move on to other operators, then I lose the ConnectableObservable reference. I would like to not include refCount as part of the method impl, and return ConnectableObservable to let consumers decide. Is there a way to achieve this?
Copy code
fun <T> Observable<T>.foo(): ConnectableObservable<T> {
  return someOperators...
         .replay(1)
         .someMoreOperators...
}
I could add a parameter
connectionStrategy: (ConnectableObservable<T>) -> Observable<T>
and apply it right after the .replay, but that feels dirty