1
val observable = Observable(...)
    .publish
val subscription = observable.connect

observable.doOnsubscribe(() => doSomething)
    .subscribe()

The doSomething is never called. The exact same code for RxJava was working properly. It seems for whatever reason it was never propagated to the underlying Java Observable

Update: So my workaround is

observable.asJavaObservable
    .doOnSubscribe(new Action0 {
        override def call(): Unit = {
            doSomething
        }
    }}.asScala
    .subscribe()
Wins
  • 3,420
  • 4
  • 36
  • 70

1 Answers1

0

publish creates a connected Observable. This is a bit different from a standard Observable and you need to call connect() in order for the connected Observable to start emitting. See the documentation here.

JohnWowUs
  • 3,053
  • 1
  • 13
  • 20
  • I did call connect, it's just I omitted here to focus on what matters. What matters is that the exact same code in RxJava or in my workaround works, but not in pure RxScala. Let me just put the connect if that makes it clearer – Wins Jan 11 '17 at 08:15
  • 1
    There seems to be a problem with your signature. See [this question](http://stackoverflow.com/questions/36274683/why-doesnt-this-execute-the-function-given-for-rxscalas-doonsubscribe-function). – JohnWowUs Jan 11 '17 at 08:27
  • your hint solve the problem. You can post it as answer and I'll mark it as the right answer – Wins Jan 31 '17 at 04:19