These are chat archives for ReactiveX/RxJava

16th
Jul 2017
Ivan Schütz
@i-schuetz
Jul 16 2017 16:17
why are doOnComplete, doOnSubscribe and doFinally never called?
//    val obs = createObservable()
    val obs = createcompletable()

    @JvmStatic fun main(args: Array<String>) {

        this.obs.doOnSubscribe {
            println("on subscribe!")

        }
        this.obs.doOnComplete {
            println("complete!")
        }

        this.obs.doFinally{
            println("dofinally!")
        }

        this.obs.subscribe {
            println("subscribe!")
        }
    }



    fun createcompletable(): Completable =
        Completable.create{ emitter ->

            println("calling oncomplete")
            emitter.onComplete()
        }

    fun createObservable(): Observable<Void> =
//        Observable.defer {
            Observable.create<Void> { emitter ->

                println("calling oncomplete")
                emitter.onComplete()
            }
//        }
+ also, the subscribe block is called only when using Completable, with Observable<Void> not even that is called
Ivan Schütz
@i-schuetz
Jul 16 2017 23:34
p.s. for completeness, I'm asking about both Observable<Void> (which is commented in the snippet) and Completable.