1 |
|
2 | import { Observable } from './Observable';
|
3 | import { Subscription } from './Subscription';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | declare global {
|
9 | interface SymbolConstructor {
|
10 | readonly observable: symbol;
|
11 | }
|
12 | }
|
13 |
|
14 | export interface UnaryFunction<T, R> {
|
15 | (source: T): R;
|
16 | }
|
17 | export interface OperatorFunction<T, R> extends UnaryFunction<Observable<T>, Observable<R>> {
|
18 | }
|
19 | export declare type FactoryOrValue<T> = T | (() => T);
|
20 | export interface MonoTypeOperatorFunction<T> extends OperatorFunction<T, T> {
|
21 | }
|
22 | /**
|
23 | * A value and the time at which it was emitted.
|
24 | *
|
25 | * Emitted by the `timestamp` operator
|
26 | *
|
27 | * @see {@link timestamp}
|
28 | */
|
29 | export interface Timestamp<T> {
|
30 | value: T;
|
31 | /**
|
32 | * The timestamp. By default, this is in epoch milliseconds.
|
33 | * Could vary based on the timestamp provider passed to the operator.
|
34 | */
|
35 | timestamp: number;
|
36 | }
|
37 | /**
|
38 | * A value emitted and the amount of time since the last value was emitted.
|
39 | *
|
40 | * Emitted by the `timeInterval` operator.
|
41 | *
|
42 | * @see {@link timeInterval}
|
43 | */
|
44 | export interface TimeInterval<T> {
|
45 | value: T;
|
46 | /**
|
47 | * The amount of time between this value's emission and the previous value's emission.
|
48 | * If this is the first emitted value, then it will be the amount of time since subscription
|
49 | * started.
|
50 | */
|
51 | interval: number;
|
52 | }
|
53 | /** SUBSCRIPTION INTERFACES */
|
54 | export interface Unsubscribable {
|
55 | unsubscribe(): void;
|
56 | }
|
57 | export declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void;
|
58 | export interface SubscriptionLike extends Unsubscribable {
|
59 | unsubscribe(): void;
|
60 | readonly closed: boolean;
|
61 | }
|
62 | /**
|
63 | * @deprecated Do not use. Most likely you want to use `ObservableInput`. Will be removed in v8.
|
64 | */
|
65 | export declare type SubscribableOrPromise<T> = Subscribable<T> | Subscribable<never> | PromiseLike<T> | InteropObservable<T>;
|
66 | /** OBSERVABLE INTERFACES */
|
67 | export interface Subscribable<T> {
|
68 | subscribe(observer: Partial<Observer<T>>): Unsubscribable;
|
69 | }
|
70 | /**
|
71 | * Valid types that can be converted to observables.
|
72 | */
|
73 | export declare type ObservableInput<T> = Observable<T> | InteropObservable<T> | AsyncIterable<T> | PromiseLike<T> | ArrayLike<T> | Iterable<T> | ReadableStreamLike<T>;
|
74 | /**
|
75 | * @deprecated Renamed to {@link InteropObservable }. Will be removed in v8.
|
76 | */
|
77 | export declare type ObservableLike<T> = InteropObservable<T>;
|
78 | /**
|
79 | * An object that implements the `Symbol.observable` interface.
|
80 | */
|
81 | export interface InteropObservable<T> {
|
82 | [Symbol.observable]: () => Subscribable<T>;
|
83 | }
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | export interface NextNotification<T> {
|
90 |
|
91 | kind: 'N';
|
92 |
|
93 | value: T;
|
94 | }
|
95 |
|
96 |
|
97 |
|
98 |
|
99 | export interface ErrorNotification {
|
100 |
|
101 | kind: 'E';
|
102 | error: any;
|
103 | }
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | export interface CompleteNotification {
|
109 | kind: 'C';
|
110 | }
|
111 |
|
112 |
|
113 |
|
114 | export declare type ObservableNotification<T> = NextNotification<T> | ErrorNotification | CompleteNotification;
|
115 |
|
116 | export interface NextObserver<T> {
|
117 | closed?: boolean;
|
118 | next: (value: T) => void;
|
119 | error?: (err: any) => void;
|
120 | complete?: () => void;
|
121 | }
|
122 | export interface ErrorObserver<T> {
|
123 | closed?: boolean;
|
124 | next?: (value: T) => void;
|
125 | error: (err: any) => void;
|
126 | complete?: () => void;
|
127 | }
|
128 | export interface CompletionObserver<T> {
|
129 | closed?: boolean;
|
130 | next?: (value: T) => void;
|
131 | error?: (err: any) => void;
|
132 | complete: () => void;
|
133 | }
|
134 | export declare type PartialObserver<T> = NextObserver<T> | ErrorObserver<T> | CompletionObserver<T>;
|
135 | export interface Observer<T> {
|
136 | next: (value: T) => void;
|
137 | error: (err: any) => void;
|
138 | complete: () => void;
|
139 | }
|
140 | export interface SubjectLike<T> extends Observer<T>, Subscribable<T> {
|
141 | }
|
142 |
|
143 | export interface SchedulerLike extends TimestampProvider {
|
144 | schedule<T>(work: (this: SchedulerAction<T>, state: T) => void, delay: number, state: T): Subscription;
|
145 | schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay: number, state?: T): Subscription;
|
146 | schedule<T>(work: (this: SchedulerAction<T>, state?: T) => void, delay?: number, state?: T): Subscription;
|
147 | }
|
148 | export interface SchedulerAction<T> extends Subscription {
|
149 | schedule(state?: T, delay?: number): Subscription;
|
150 | }
|
151 | /**
|
152 | * This is a type that provides a method to allow RxJS to create a numeric timestamp
|
153 | */
|
154 | export interface TimestampProvider {
|
155 | /**
|
156 | * Returns a timestamp as a number.
|
157 | *
|
158 | * This is used by types like `ReplaySubject` or operators like `timestamp` to calculate
|
159 | * the amount of time passed between events.
|
160 | */
|
161 | now(): number;
|
162 | }
|
163 | /**
|
164 | * Extracts the type from an `ObservableInput<any>`. If you have
|
165 | * `O extends ObservableInput<any>` and you pass in `Observable<number>`, or
|
166 | * `Promise<number>`, etc, it will type as `number`.
|
167 | */
|
168 | export declare type ObservedValueOf<O> = O extends ObservableInput<infer T> ? T : never;
|
169 | /**
|
170 | * Extracts a union of element types from an `ObservableInput<any>[]`.
|
171 | * If you have `O extends ObservableInput<any>[]` and you pass in
|
172 | * `Observable<string>[]` or `Promise<string>[]` you would get
|
173 | * back a type of `string`.
|
174 | * If you pass in `[Observable<string>, Observable<number>]` you would
|
175 | * get back a type of `string | number`.
|
176 | */
|
177 | export declare type ObservedValueUnionFromArray<X> = X extends Array<ObservableInput<infer T>> ? T : never;
|
178 | /**
|
179 | * @deprecated Renamed to {@link ObservedValueUnionFromArray}. Will be removed in v8.
|
180 | */
|
181 | export declare type ObservedValuesFromArray<X> = ObservedValueUnionFromArray<X>;
|
182 | /**
|
183 | * Extracts a tuple of element types from an `ObservableInput<any>[]`.
|
184 | * If you have `O extends ObservableInput<any>[]` and you pass in
|
185 | * `[Observable<string>, Observable<number>]` you would get back a type
|
186 | * of `[string, number]`.
|
187 | */
|
188 | export declare type ObservedValueTupleFromArray<X> = {
|
189 | [K in keyof X]: ObservedValueOf<X[K]>;
|
190 | };
|
191 | /**
|
192 | * Used to infer types from arguments to functions like {@link forkJoin}.
|
193 | * So that you can have `forkJoin([Observable<A>, PromiseLike<B>]): Observable<[A, B]>`
|
194 | * et al.
|
195 | */
|
196 | export declare type ObservableInputTuple<T> = {
|
197 | [K in keyof T]: ObservableInput<T[K]>;
|
198 | };
|
199 | /**
|
200 | * Constructs a new tuple with the specified type at the head.
|
201 | * If you declare `Cons<A, [B, C]>` you will get back `[A, B, C]`.
|
202 | */
|
203 | export declare type Cons<X, Y extends readonly any[]> = ((arg: X, ...rest: Y) => any) extends (...args: infer U) => any ? U : never;
|
204 |
|
205 |
|
206 |
|
207 |
|
208 | export declare type Head<X extends readonly any[]> = ((...args: X) => any) extends (arg: infer U, ...rest: any[]) => any ? U : never;
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | export declare type Tail<X extends readonly any[]> = ((...args: X) => any) extends (arg: any, ...rest: infer U) => any ? U : never;
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | export declare type ValueFromArray<A extends readonly unknown[]> = A extends Array<infer T> ? T : never;
|
220 |
|
221 |
|
222 |
|
223 | export declare type ValueFromNotification<T> = T extends {
|
224 | kind: 'N' | 'E' | 'C';
|
225 | } ? T extends NextNotification<any> ? T extends {
|
226 | value: infer V;
|
227 | } ? V : undefined : never : never;
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 | export declare type Falsy = null | undefined | false | 0 | -0 | 0n | '';
|
234 | export declare type TruthyTypesOf<T> = T extends Falsy ? never : T;
|
235 | interface ReadableStreamDefaultReaderLike<T> {
|
236 | read(): PromiseLike<{
|
237 | done: false;
|
238 | value: T;
|
239 | } | {
|
240 | done: true;
|
241 | value?: undefined;
|
242 | }>;
|
243 | releaseLock(): void;
|
244 | }
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 | export interface ReadableStreamLike<T> {
|
251 | getReader(): ReadableStreamDefaultReaderLike<T>;
|
252 | }
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | export interface Connectable<T> extends Observable<T> {
|
258 | |
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 | connect(): Subscription;
|
265 | }
|
266 | export {};
|
267 |
|
\ | No newline at end of file |