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