source: trip-planner-front/node_modules/rxjs/internal/operators/observeOn.d.ts@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.3 KB
Line 
1import { Operator } from '../Operator';
2import { Subscriber } from '../Subscriber';
3import { Notification } from '../Notification';
4import { MonoTypeOperatorFunction, PartialObserver, SchedulerAction, SchedulerLike, TeardownLogic } from '../types';
5/**
6 *
7 * Re-emits all notifications from source Observable with specified scheduler.
8 *
9 * <span class="informal">Ensure a specific scheduler is used, from outside of an Observable.</span>
10 *
11 * `observeOn` is an operator that accepts a scheduler as a first parameter, which will be used to reschedule
12 * notifications emitted by the source Observable. It might be useful, if you do not have control over
13 * internal scheduler of a given Observable, but want to control when its values are emitted nevertheless.
14 *
15 * Returned Observable emits the same notifications (nexted values, complete and error events) as the source Observable,
16 * but rescheduled with provided scheduler. Note that this doesn't mean that source Observables internal
17 * scheduler will be replaced in any way. Original scheduler still will be used, but when the source Observable emits
18 * notification, it will be immediately scheduled again - this time with scheduler passed to `observeOn`.
19 * An anti-pattern would be calling `observeOn` on Observable that emits lots of values synchronously, to split
20 * that emissions into asynchronous chunks. For this to happen, scheduler would have to be passed into the source
21 * Observable directly (usually into the operator that creates it). `observeOn` simply delays notifications a
22 * little bit more, to ensure that they are emitted at expected moments.
23 *
24 * As a matter of fact, `observeOn` accepts second parameter, which specifies in milliseconds with what delay notifications
25 * will be emitted. The main difference between {@link delay} operator and `observeOn` is that `observeOn`
26 * will delay all notifications - including error notifications - while `delay` will pass through error
27 * from source Observable immediately when it is emitted. In general it is highly recommended to use `delay` operator
28 * for any kind of delaying of values in the stream, while using `observeOn` to specify which scheduler should be used
29 * for notification emissions in general.
30 *
31 * ## Example
32 * Ensure values in subscribe are called just before browser repaint.
33 * ```ts
34 * import { interval } from 'rxjs';
35 * import { observeOn } from 'rxjs/operators';
36 *
37 * const intervals = interval(10); // Intervals are scheduled
38 * // with async scheduler by default...
39 * intervals.pipe(
40 * observeOn(animationFrameScheduler), // ...but we will observe on animationFrame
41 * ) // scheduler to ensure smooth animation.
42 * .subscribe(val => {
43 * someDiv.style.height = val + 'px';
44 * });
45 * ```
46 *
47 * @see {@link delay}
48 *
49 * @param {SchedulerLike} scheduler Scheduler that will be used to reschedule notifications from source Observable.
50 * @param {number} [delay] Number of milliseconds that states with what delay every notification should be rescheduled.
51 * @return {Observable<T>} Observable that emits the same notifications as the source Observable,
52 * but with provided scheduler.
53 *
54 * @method observeOn
55 * @owner Observable
56 */
57export declare function observeOn<T>(scheduler: SchedulerLike, delay?: number): MonoTypeOperatorFunction<T>;
58export declare class ObserveOnOperator<T> implements Operator<T, T> {
59 private scheduler;
60 private delay;
61 constructor(scheduler: SchedulerLike, delay?: number);
62 call(subscriber: Subscriber<T>, source: any): TeardownLogic;
63}
64/**
65 * We need this JSDoc comment for affecting ESDoc.
66 * @ignore
67 * @extends {Ignored}
68 */
69export declare class ObserveOnSubscriber<T> extends Subscriber<T> {
70 private scheduler;
71 private delay;
72 /** @nocollapse */
73 static dispatch(this: SchedulerAction<ObserveOnMessage>, arg: ObserveOnMessage): void;
74 constructor(destination: Subscriber<T>, scheduler: SchedulerLike, delay?: number);
75 private scheduleMessage;
76 protected _next(value: T): void;
77 protected _error(err: any): void;
78 protected _complete(): void;
79}
80export declare class ObserveOnMessage {
81 notification: Notification<any>;
82 destination: PartialObserver<any>;
83 constructor(notification: Notification<any>, destination: PartialObserver<any>);
84}
Note: See TracBrowser for help on using the repository browser.