Description
If you dispatch an action soon after creating the epic middleware, the returned Observable from the map function needs to start the subscription synchronously. If you subscribe with a different scheduler (subscribeOn), a race condition is created and events could be emitted before subscribers are ready.
Steps to reproduce the behavior
On the "create" test here Tests, make the returned observable subscribe on a different scheduler. Eg. .subscribeOn(Schedulers.io())
Investigation
At this point it is assumed that the actions subject has observers, however the actions.hasObservers() function shows that is not true.
What I think is happening is that since we are subscribing on a different thread in the epic observable, the function continues and emits an item before the observable is ready to receive items.
Description
If you dispatch an action soon after creating the epic middleware, the returned
Observablefrom themapfunction needs to start the subscription synchronously. If you subscribe with a different scheduler (subscribeOn), a race condition is created and events could be emitted before subscribers are ready.Steps to reproduce the behavior
On the "create" test here Tests, make the returned observable subscribe on a different scheduler. Eg.
.subscribeOn(Schedulers.io())Investigation
At this point it is assumed that the
actionssubject has observers, however theactions.hasObservers()function shows that is not true.What I think is happening is that since we are subscribing on a different thread in the
epicobservable, the function continues and emits an item before the observable is ready to receive items.