///
import { Observable } from './Observable';
import { Subscription } from './Subscription';
/**
* Note: This will add Symbol.observable globally for all TypeScript users,
* however, we are no longer polyfilling Symbol.observable
*/
declare global {
interface SymbolConstructor {
readonly observable: symbol;
}
}
/** OPERATOR INTERFACES */
export interface UnaryFunction {
(source: T): R;
}
export interface OperatorFunction extends UnaryFunction, Observable> {
}
export declare type FactoryOrValue = T | (() => T);
export interface MonoTypeOperatorFunction extends OperatorFunction {
}
/**
* A value and the time at which it was emitted.
*
* Emitted by the `timestamp` operator
*
* @see {@link timestamp}
*/
export interface Timestamp {
value: T;
/**
* The timestamp. By default, this is in epoch milliseconds.
* Could vary based on the timestamp provider passed to the operator.
*/
timestamp: number;
}
/**
* A value emitted and the amount of time since the last value was emitted.
*
* Emitted by the `timeInterval` operator.
*
* @see {@link timeInterval}
*/
export interface TimeInterval {
value: T;
/**
* The amount of time between this value's emission and the previous value's emission.
* If this is the first emitted value, then it will be the amount of time since subscription
* started.
*/
interval: number;
}
/** SUBSCRIPTION INTERFACES */
export interface Unsubscribable {
unsubscribe(): void;
}
export declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void;
export interface SubscriptionLike extends Unsubscribable {
unsubscribe(): void;
readonly closed: boolean;
}
/**
* @deprecated Do not use. Most likely you want to use `ObservableInput`. Will be removed in v8.
*/
export declare type SubscribableOrPromise = Subscribable | Subscribable | PromiseLike | InteropObservable;
/** OBSERVABLE INTERFACES */
export interface Subscribable {
subscribe(observer: Partial>): Unsubscribable;
}
/**
* Valid types that can be converted to observables.
*/
export declare type ObservableInput = Observable | InteropObservable | AsyncIterable | PromiseLike | ArrayLike | Iterable | ReadableStreamLike;
/**
* @deprecated Renamed to {@link InteropObservable }. Will be removed in v8.
*/
export declare type ObservableLike = InteropObservable;
/**
* An object that implements the `Symbol.observable` interface.
*/
export interface InteropObservable {
[Symbol.observable]: () => Subscribable;
}
/** NOTIFICATIONS */
/**
* A notification representing a "next" from an observable.
* Can be used with {@link dematerialize}.
*/
export interface NextNotification {
/** The kind of notification. Always "N" */
kind: 'N';
/** The value of the notification. */
value: T;
}
/**
* A notification representing an "error" from an observable.
* Can be used with {@link dematerialize}.
*/
export interface ErrorNotification {
/** The kind of notification. Always "E" */
kind: 'E';
error: any;
}
/**
* A notification representing a "completion" from an observable.
* Can be used with {@link dematerialize}.
*/
export interface CompleteNotification {
kind: 'C';
}
/**
* Valid observable notification types.
*/
export declare type ObservableNotification = NextNotification | ErrorNotification | CompleteNotification;
/** OBSERVER INTERFACES */
export interface NextObserver {
closed?: boolean;
next: (value: T) => void;
error?: (err: any) => void;
complete?: () => void;
}
export interface ErrorObserver {
closed?: boolean;
next?: (value: T) => void;
error: (err: any) => void;
complete?: () => void;
}
export interface CompletionObserver {
closed?: boolean;
next?: (value: T) => void;
error?: (err: any) => void;
complete: () => void;
}
export declare type PartialObserver = NextObserver | ErrorObserver | CompletionObserver;
export interface Observer {
next: (value: T) => void;
error: (err: any) => void;
complete: () => void;
}
export interface SubjectLike extends Observer, Subscribable {
}
/** SCHEDULER INTERFACES */
export interface SchedulerLike extends TimestampProvider {
schedule(work: (this: SchedulerAction, state: T) => void, delay: number, state: T): Subscription;
schedule(work: (this: SchedulerAction, state?: T) => void, delay: number, state?: T): Subscription;
schedule(work: (this: SchedulerAction, state?: T) => void, delay?: number, state?: T): Subscription;
}
export interface SchedulerAction extends Subscription {
schedule(state?: T, delay?: number): Subscription;
}
/**
* This is a type that provides a method to allow RxJS to create a numeric timestamp
*/
export interface TimestampProvider {
/**
* Returns a timestamp as a number.
*
* This is used by types like `ReplaySubject` or operators like `timestamp` to calculate
* the amount of time passed between events.
*/
now(): number;
}
/**
* Extracts the type from an `ObservableInput`. If you have
* `O extends ObservableInput` and you pass in `Observable`, or
* `Promise`, etc, it will type as `number`.
*/
export declare type ObservedValueOf = O extends ObservableInput ? T : never;
/**
* Extracts a union of element types from an `ObservableInput[]`.
* If you have `O extends ObservableInput[]` and you pass in
* `Observable[]` or `Promise[]` you would get
* back a type of `string`.
* If you pass in `[Observable, Observable]` you would
* get back a type of `string | number`.
*/
export declare type ObservedValueUnionFromArray = X extends Array> ? T : never;
/**
* @deprecated Renamed to {@link ObservedValueUnionFromArray}. Will be removed in v8.
*/
export declare type ObservedValuesFromArray = ObservedValueUnionFromArray;
/**
* Extracts a tuple of element types from an `ObservableInput[]`.
* If you have `O extends ObservableInput[]` and you pass in
* `[Observable, Observable]` you would get back a type
* of `[string, number]`.
*/
export declare type ObservedValueTupleFromArray = {
[K in keyof X]: ObservedValueOf;
};
/**
* Used to infer types from arguments to functions like {@link forkJoin}.
* So that you can have `forkJoin([Observable, PromiseLike]): Observable<[A, B]>`
* et al.
*/
export declare type ObservableInputTuple = {
[K in keyof T]: ObservableInput;
};
/**
* Constructs a new tuple with the specified type at the head.
* If you declare `Cons` you will get back `[A, B, C]`.
*/
export declare type Cons = ((arg: X, ...rest: Y) => any) extends (...args: infer U) => any ? U : never;
/**
* Extracts the head of a tuple.
* If you declare `Head<[A, B, C]>` you will get back `A`.
*/
export declare type Head = ((...args: X) => any) extends (arg: infer U, ...rest: any[]) => any ? U : never;
/**
* Extracts the tail of a tuple.
* If you declare `Tail<[A, B, C]>` you will get back `[B, C]`.
*/
export declare type Tail = ((...args: X) => any) extends (arg: any, ...rest: infer U) => any ? U : never;
/**
* Extracts the generic value from an Array type.
* If you have `T extends Array`, and pass a `string[]` to it,
* `ValueFromArray` will return the actual type of `string`.
*/
export declare type ValueFromArray = A extends Array ? T : never;
/**
* Gets the value type from an {@link ObservableNotification}, if possible.
*/
export declare type ValueFromNotification = T extends {
kind: 'N' | 'E' | 'C';
} ? T extends NextNotification ? T extends {
value: infer V;
} ? V : undefined : never : never;
/**
* A simple type to represent a gamut of "falsy" values... with a notable exception:
* `NaN` is "falsy" however, it is not and cannot be typed via TypeScript. See
* comments here: https://github.com/microsoft/TypeScript/issues/28682#issuecomment-707142417
*/
export declare type Falsy = null | undefined | false | 0 | -0 | 0n | '';
export declare type TruthyTypesOf = T extends Falsy ? never : T;
interface ReadableStreamDefaultReaderLike {
read(): PromiseLike<{
done: false;
value: T;
} | {
done: true;
value?: undefined;
}>;
releaseLock(): void;
}
/**
* The base signature RxJS will look for to identify and use
* a [ReadableStream](https://streams.spec.whatwg.org/#rs-class)
* as an {@link ObservableInput} source.
*/
export interface ReadableStreamLike {
getReader(): ReadableStreamDefaultReaderLike;
}
/**
* An observable with a `connect` method that is used to create a subscription
* to an underlying source, connecting it with all consumers via a multicast.
*/
export interface Connectable extends Observable {
/**
* (Idempotent) Calling this method will connect the underlying source observable to all subscribed consumers
* through an underlying {@link Subject}.
* @returns A subscription, that when unsubscribed, will "disconnect" the source from the connector subject,
* severing notifications to all consumers.
*/
connect(): Subscription;
}
export {};
//# sourceMappingURL=types.d.ts.map