As far as I know in older RxJS 4 I could change default scheduler by monkey patching DefaultScheduler.prototype
. Is that correct or maybe there is a better way to do this?
Is this possible to achieve in newer RxJS 5. Because as I have seen in the sources, they use null
as a default scheduler which can not be monkey patched. For example here
So how can I change the default scheduler used by RxJS? (for testing, debugging or just for fun)
I don't think there's a way to set a default Scheduler in RxJS 5.
One reason could be that this might lead to unexpected behavior. For example have a look at Observable.range()
. In RxJS 5 it doesn't use any scheduler unless you specifically set one, see https://github.com/ReactiveX/rxjs/blob/master/src/observable/RangeObservable.ts#L89
So if you could use some default scheduler what behavior you'd expect from Observable.range()
? To always use this default scheduler? And what about other operators that need to use some async scheduling? Should these pass the scheduler along to other operators that work similarly to Observable.range()
which might behave differently than you expect?