1 | import { Operator } from './Operator';
|
2 | import { Subscriber } from './Subscriber';
|
3 | import { Subscription } from './Subscription';
|
4 | import { TeardownLogic, OperatorFunction, Subscribable, Observer } from './types';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export declare class Observable<T> implements Subscribable<T> {
|
12 | |
13 |
|
14 |
|
15 | source: Observable<any> | undefined;
|
16 | |
17 |
|
18 |
|
19 | operator: Operator<any, T> | undefined;
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic);
|
28 | /**
|
29 | * Creates a new Observable by calling the Observable constructor
|
30 | * @owner Observable
|
31 | * @method create
|
32 | * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
|
33 | * @return {Observable} a new observable
|
34 | * @nocollapse
|
35 | * @deprecated Use `new Observable()` instead. Will be removed in v8.
|
36 | */
|
37 | static create: (...args: any[]) => any;
|
38 | /**
|
39 | * Creates a new Observable, with this Observable instance as the source, and the passed
|
40 | * operator defined as the new observable's operator.
|
41 | * @method lift
|
42 | * @param operator the operator defining the operation to take on the observable
|
43 | * @return a new observable with the Operator applied
|
44 | * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
|
45 | * If you have implemented an operator using `lift`, it is recommended that you create an
|
46 | * operator by simply returning `new Observable()` directly. See "Creating new operators from
|
47 | * scratch" section here: https://rxjs.dev/guide/operators
|
48 | */
|
49 | lift<R>(operator?: Operator<T, R>): Observable<R>;
|
50 | subscribe(observerOrNext?: Partial<Observer<T>> | ((value: T) => void)): Subscription;
|
51 | /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */
|
52 | subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
|
53 | /**
|
54 | * Used as a NON-CANCELLABLE means of subscribing to an observable, for use with
|
55 | * APIs that expect promises, like `async/await`. You cannot unsubscribe from this.
|
56 | *
|
57 | * **WARNING**: Only use this with observables you *know* will complete. If the source
|
58 | * observable does not complete, you will end up with a promise that is hung up, and
|
59 | * potentially all of the state of an async function hanging out in memory. To avoid
|
60 | * this situation, look into adding something like {@link timeout}, {@link take},
|
61 | * {@link takeWhile}, or {@link takeUntil} amongst others.
|
62 | *
|
63 | * #### Example
|
64 | *
|
65 | * ```ts
|
66 | * import { interval, take } from 'rxjs';
|
67 | *
|
68 | * const source$ = interval(1000).pipe(take(4));
|
69 | *
|
70 | * async function getTotal() {
|
71 | * let total = 0;
|
72 | *
|
73 | * await source$.forEach(value => {
|
74 | * total += value;
|
75 | * console.log('observable -> ' + value);
|
76 | * });
|
77 | *
|
78 | * return total;
|
79 | * }
|
80 | *
|
81 | * getTotal().then(
|
82 | * total => console.log('Total: ' + total)
|
83 | * );
|
84 | *
|
85 | * // Expected:
|
86 | * // 'observable -> 0'
|
87 | * // 'observable -> 1'
|
88 | * // 'observable -> 2'
|
89 | * // 'observable -> 3'
|
90 | * // 'Total: 6'
|
91 | * ```
|
92 | *
|
93 | * @param next a handler for each value emitted by the observable
|
94 | * @return a promise that either resolves on observable completion or
|
95 | * rejects with the handled error
|
96 | */
|
97 | forEach(next: (value: T) => void): Promise<void>;
|
98 | |
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | forEach(next: (value: T) => void, promiseCtor: PromiseConstructorLike): Promise<void>;
|
110 | pipe(): Observable<T>;
|
111 | pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;
|
112 | pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;
|
113 | pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;
|
114 | pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>;
|
115 | 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>;
|
116 | 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>;
|
117 | 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>;
|
118 | 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>;
|
119 | 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>;
|
120 | 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<unknown>;
|
121 |
|
122 | toPromise(): Promise<T | undefined>;
|
123 |
|
124 | toPromise(PromiseCtor: typeof Promise): Promise<T | undefined>;
|
125 |
|
126 | toPromise(PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;
|
127 | }
|
128 |
|
\ | No newline at end of file |