juliocbcotta
05/25/2017, 6:36 PMval subject = PublishSubject.create<String>()
subject.startWith("")
.flatMap { it -> Observable.just(it.hashCode()) }
.doOnNext { it -> subject.onNext(it.toString()) }
.take(10)
.subscribe { it -> Log.d("testing the application", it.toString()) }
and this test
val subject = PublishSubject.create<String>()
subject.startWith("")
.flatMap { it -> Observable.just(it.hashCode()).delay(100, TimeUnit.MILLISECONDS) }
.doOnNext { it -> subject.onNext(it.toString()) }
.take(10)
.subscribe { it -> Log.d("testing the application", it.toString()) }
The only difference it the .delay(100, TimeUnit.MILLISECONDS)
in the second…
In the first the log is printed only once and in the second 10 times… could someone explain it to me ?