- RxJS Tutorial
- RxJS - Home
- RxJS - Overview
- RxJS - Environment Setup
- RxJS - Latest Updates
- RxJS - Observables
- RxJS - Operators
- RxJS - Working with Subscription
- RxJS - Working with Subjects
- RxJS - Working with Scheduler
- RxJS - Working with RxJS & Angular
- RxJS - Working with RxJS & ReactJS
- RxJS Useful Resources
- RxJS - Quick Guide
- RxJS - Useful Resources
- RxJS - Discussion
RxJS - Utility Operator subscribeOn
This operator helps to asynchronous subscribes to the source Observable based on the scheduler taken as input.
Syntax
subscribeOn(scheduler): Observable
Parameters
scheduler − The scheduler is used as an input that will help to re-emit the notifications from the source observable.
Return value
It will return an observable same as source observable, but with scheduler param.
Example
import { of, merge, asyncScheduler } from 'rxjs'; import { subscribeOn } from 'rxjs/operators'; let test1 = of(2, 4, 6, 8).pipe(subscribeOn(asyncScheduler)); let test2 = of(3, 6, 9, 12, 15); let sub1 = merge(test1, test2).subscribe(console.log);
Output
Advertisements