1 import { MonoTypeOperatorFunction, SchedulerLike } from '../types';
3 * Asynchronously subscribes Observers to this Observable on the specified {@link SchedulerLike}.
5 * With `subscribeOn` you can decide what type of scheduler a specific Observable will be using when it is subscribed to.
7 * Schedulers control the speed and order of emissions to observers from an Observable stream.
12 * Given the following code:
14 * import { of, merge } from 'rxjs';
16 * const a = of(1, 2, 3, 4);
17 * const b = of(5, 6, 7, 8, 9);
18 * merge(a, b).subscribe(console.log);
21 * Both Observable `a` and `b` will emit their values directly and synchronously once they are subscribed to.
22 * This will result in the output of `1 2 3 4 5 6 7 8 9`.
24 * But if we instead us the `subscribeOn` operator declaring that we want to use the {@link asyncScheduler} for values emited by Observable `a`:
26 * import { of, merge, asyncScheduler } from 'rxjs';
27 * import { subscribeOn } from 'rxjs/operators';
29 * const a = of(1, 2, 3, 4).pipe(subscribeOn(asyncScheduler));
30 * const b = of(5, 6, 7, 8, 9);
31 * merge(a, b).subscribe(console.log);
34 * The output will instead be `5 6 7 8 9 1 2 3 4`.
35 * The reason for this is that Observable `b` emits its values directly and synchronously like before
36 * but the emissions from `a` are scheduled on the event loop because we are now using the {@link asyncScheduler} for that specific Observable.
38 * @param {SchedulerLike} scheduler - The {@link SchedulerLike} to perform subscription actions on.
39 * @return {Observable<T>} The source Observable modified so that its subscriptions happen on the specified {@link SchedulerLike}.
44 export declare function subscribeOn<T>(scheduler: SchedulerLike, delay?: number): MonoTypeOperatorFunction<T>;