UNPKG

6.07 kBTypeScriptView Raw
1import { Operator } from './Operator';
2import { Subscriber } from './Subscriber';
3import { Subscription } from './Subscription';
4import { TeardownLogic, OperatorFunction, PartialObserver, Subscribable } from './types';
5import { iif } from './observable/iif';
6import { throwError } from './observable/throwError';
7/**
8 * A representation of any set of values over any amount of time. This is the most basic building block
9 * of RxJS.
10 *
11 * @class Observable<T>
12 */
13export declare class Observable<T> implements Subscribable<T> {
14 /** Internal implementation detail, do not use directly. */
15 _isScalar: boolean;
16 /** @deprecated This is an internal implementation detail, do not use. */
17 source: Observable<any>;
18 /** @deprecated This is an internal implementation detail, do not use. */
19 operator: Operator<any, T>;
20 /**
21 * @constructor
22 * @param {Function} subscribe the function that is called when the Observable is
23 * initially subscribed to. This function is given a Subscriber, to which new values
24 * can be `next`ed, or an `error` method can be called to raise an error, or
25 * `complete` can be called to notify of a successful completion.
26 */
27 constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic);
28 /**
29 * Creates a new cold Observable by calling the Observable constructor
30 * @static true
31 * @owner Observable
32 * @method create
33 * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
34 * @return {Observable} a new cold observable
35 * @nocollapse
36 * @deprecated use new Observable() instead
37 */
38 static create: Function;
39 /**
40 * Creates a new Observable, with this Observable as the source, and the passed
41 * operator defined as the new observable's operator.
42 * @method lift
43 * @param {Operator} operator the operator defining the operation to take on the observable
44 * @return {Observable} a new observable with the Operator applied
45 */
46 lift<R>(operator: Operator<T, R>): Observable<R>;
47 subscribe(observer?: PartialObserver<T>): Subscription;
48 /** @deprecated Use an observer instead of a complete callback */
49 subscribe(next: null | undefined, error: null | undefined, complete: () => void): Subscription;
50 /** @deprecated Use an observer instead of an error callback */
51 subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Subscription;
52 /** @deprecated Use an observer instead of a complete callback */
53 subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Subscription;
54 subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;
55 /** @deprecated This is an internal implementation detail, do not use. */
56 _trySubscribe(sink: Subscriber<T>): TeardownLogic;
57 /**
58 * @method forEach
59 * @param {Function} next a handler for each value emitted by the observable
60 * @param {PromiseConstructor} [promiseCtor] a constructor function used to instantiate the Promise
61 * @return {Promise} a promise that either resolves on observable completion or
62 * rejects with the handled error
63 */
64 forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void>;
65 /** @internal This is an internal implementation detail, do not use. */
66 _subscribe(subscriber: Subscriber<any>): TeardownLogic;
67 /**
68 * @nocollapse
69 * @deprecated In favor of iif creation function: import { iif } from 'rxjs';
70 */
71 static if: typeof iif;
72 /**
73 * @nocollapse
74 * @deprecated In favor of throwError creation function: import { throwError } from 'rxjs';
75 */
76 static throw: typeof throwError;
77 pipe(): Observable<T>;
78 pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;
79 pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;
80 pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;
81 pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>;
82 pipe<A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): Observable<E>;
83 pipe<A, B, C, D, E, F>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): Observable<F>;
84 pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): Observable<G>;
85 pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): Observable<H>;
86 pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): Observable<I>;
87 pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<{}>;
88 toPromise<T>(this: Observable<T>): Promise<T>;
89 toPromise<T>(this: Observable<T>, PromiseCtor: typeof Promise): Promise<T>;
90 toPromise<T>(this: Observable<T>, PromiseCtor: PromiseConstructorLike): Promise<T>;
91}