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