while learing rxjava/rxandroid i have came across one scenario. please help me to understand it. please check below code.
val observable:Observable<Int> = Observable.create {
Log.d(TAG, "start emission")
it.onNext(1)
it.onNext(2)
it.onNext(3)
it.onError(RuntimeException())
Log.d(TAG, "isObserverDispose: ${it.isDisposed}")
it.onNext(4)
Log.d(TAG, "end emission")
}
val v = observable.subscribe({
Log.d(TAG, "onNext: $it")
},{
Log.d(TAG, "onError: $it")
})
output
MainActivity: start emission
MainActivity: onNext: 1
MainActivity: onNext: 2
MainActivity: onNext: 3
MainActivity: onError: java.lang.RuntimeException
MainActivity: isObserverDispose: true
MainActivity: end emission
so as per my understanding, After calling onError(3) subscription need to end and if there is any emission after ending subscription, app will crash. But as per output app is not crashing. Can someone help me to understand what is going here.