Closed ykinuse closed 6 years ago
This is a valid behavior. The PublishSubject
is not subscribed at that time because startWith
hasn't finished yet switching to it. Consider using BehaviorSubject.create(0)
instead and not doing that reentrant onNext
call.
Thanks for the clarification. PublishSubject was used as an example of some source. So I'm assuming doOnSubscribe() chained after startWith does not guaranteed subscription established to the source? Was expecting a guaranteed subscription to source before startWith emits.
No. StartWith is like concat, subscribes the next source after the previous source has completed, thus no doOnSubscribe
is called on the next source until that.
Cleared my doubts. Thanks for the swift & clear response!
Hi, I'm not sure if this is a bug or an expected behavior. See an example below:
Scenario: In my use case, I subscribed to a source that chained with a #startWith operator. I performed a switchMap, expecting the next value terminates it and starts a new one. Subject emits something during the switchmap. Happens on both Observable/Flowable.
Expected: receive the new event Actual: receive nothing due to subject not subscribed yet.
Have not tested on other version.
Thanks