///
///
declare namespace Rx {
namespace internals {
function isEqual(left: any, right: any): boolean;
function addRef(xs: Observable, r: { getDisposable(): IDisposable }): Observable;
// Priority Queue for Scheduling
class PriorityQueue {
constructor(capacity: number);
length: number;
isHigherPriority(left: number, right: number): boolean;
percolate(index: number): void;
heapify(index: number): void;
peek(): ScheduledItem;
removeAt(index: number): void;
dequeue(): ScheduledItem;
enqueue(item: ScheduledItem): void;
remove(item: ScheduledItem): boolean;
static count: number;
}
class ScheduledItem {
constructor(
scheduler: IScheduler,
state: any,
action: (scheduler: IScheduler, state: any) => IDisposable,
dueTime: TTime,
comparer?: (x: TTime, y: TTime) => number,
);
scheduler: IScheduler;
state: TTime;
action: (scheduler: IScheduler, state: any) => IDisposable;
dueTime: TTime;
comparer: (x: TTime, y: TTime) => number;
disposable: SingleAssignmentDisposable;
invoke(): void;
compareTo(other: ScheduledItem): number;
isCancelled(): boolean;
invokeCore(): IDisposable;
}
}
namespace config {
let Promise: {
new(
resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void,
): IPromise;
};
}
namespace helpers {
function noop(): void;
function notDefined(value: any): boolean;
function identity(value: T): T;
function defaultNow(): number;
function defaultComparer(left: any, right: any): boolean;
function defaultSubComparer(left: any, right: any): number;
function defaultKeySerializer(key: any): string;
function defaultError(err: any): void;
function isPromise(p: any): boolean;
function asArray(...args: T[]): T[];
function not(value: any): boolean;
function isFunction(value: any): boolean;
}
class CompositeDisposable implements IDisposable {
constructor(...disposables: IDisposable[]);
constructor(disposables: IDisposable[]);
isDisposed: boolean;
length: number;
dispose(): void;
add(item: IDisposable): void;
remove(item: IDisposable): boolean;
toArray(): IDisposable[];
}
class Disposable implements IDisposable {
constructor(action: () => void);
static create(action: () => void): IDisposable;
static empty: IDisposable;
dispose(): void;
}
// Single assignment
class SingleAssignmentDisposable implements IDisposable {
constructor();
isDisposed: boolean;
current: IDisposable;
dispose(): void;
getDisposable(): IDisposable;
setDisposable(value: IDisposable): void;
}
// SerialDisposable it's an alias of SingleAssignmentDisposable
class SerialDisposable extends SingleAssignmentDisposable {
constructor();
}
class RefCountDisposable implements IDisposable {
constructor(disposable: IDisposable);
dispose(): void;
isDisposed: boolean;
getDisposable(): IDisposable;
}
interface IScheduler {
now(): number;
isScheduler(value: any): boolean;
schedule(action: () => void): IDisposable;
scheduleWithState(
state: TState,
action: (scheduler: IScheduler, state: TState) => IDisposable,
): IDisposable;
scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable;
scheduleWithAbsoluteAndState(
state: TState,
dueTime: number,
action: (scheduler: IScheduler, state: TState) => IDisposable,
): IDisposable;
scheduleWithRelative(dueTime: number, action: () => void): IDisposable;
scheduleWithRelativeAndState(
state: TState,
dueTime: number,
action: (scheduler: IScheduler, state: TState) => IDisposable,
): IDisposable;
scheduleRecursive(action: (action: () => void) => void): IDisposable;
scheduleRecursiveWithState(
state: TState,
action: (state: TState, action: (state: TState) => void) => void,
): IDisposable;
scheduleRecursiveWithAbsolute(
dueTime: number,
action: (action: (dueTime: number) => void) => void,
): IDisposable;
scheduleRecursiveWithAbsoluteAndState(
state: TState,
dueTime: number,
action: (state: TState, action: (state: TState, dueTime: number) => void) => void,
): IDisposable;
scheduleRecursiveWithRelative(
dueTime: number,
action: (action: (dueTime: number) => void) => void,
): IDisposable;
scheduleRecursiveWithRelativeAndState(
state: TState,
dueTime: number,
action: (state: TState, action: (state: TState, dueTime: number) => void) => void,
): IDisposable;
schedulePeriodic(period: number, action: () => void): IDisposable;
schedulePeriodicWithState(
state: TState,
period: number,
action: (state: TState) => TState,
): IDisposable;
}
interface Scheduler extends IScheduler {
}
interface SchedulerStatic {
new(
now: () => number,
schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable,
scheduleRelative: (
state: any,
dueTime: number,
action: (scheduler: IScheduler, state: any) => IDisposable,
) => IDisposable,
scheduleAbsolute: (
state: any,
dueTime: number,
action: (scheduler: IScheduler, state: any) => IDisposable,
) => IDisposable,
): Scheduler;
normalize(timeSpan: number): number;
immediate: IScheduler;
currentThread: ICurrentThreadScheduler;
default: IScheduler; // alias for Scheduler.timeout
timeout: IScheduler;
}
const Scheduler: SchedulerStatic;
// Current Thread IScheduler
interface ICurrentThreadScheduler extends IScheduler {
scheduleRequired(): boolean;
}
// Notifications
class Notification {
accept(observer: IObserver): void;
accept(
onNext: (value: T) => TResult,
onError?: (exception: any) => TResult,
onCompleted?: () => TResult,
): TResult;
toObservable(scheduler?: IScheduler): Observable;
hasValue: boolean;
equals(other: Notification): boolean;
kind: string;
value: T;
exception: any;
static createOnNext(value: T): Notification;
static createOnError(exception: any): Notification;
static createOnCompleted(): Notification;
}
// Observer
interface IObserver {
onNext(value: T): void;
onError(exception: any): void;
onCompleted(): void;
}
interface Observer extends IObserver {
toNotifier(): (notification: Notification) => void;
asObserver(): Observer;
}
interface ObserverStatic {
create(
onNext?: (value: T) => void,
onError?: (exception: any) => void,
onCompleted?: () => void,
): Observer;
fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer;
}
const Observer: ObserverStatic;
interface IObservable {
subscribe(observer: Observer): IDisposable;
subscribe(
onNext?: (value: T) => void,
onError?: (exception: any) => void,
onCompleted?: () => void,
): IDisposable;
subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable;
subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable;
subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable;
}
interface Observable extends IObservable {
forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe
toArray(): Observable;
catch(handler: (exception: Error) => IPromise | Observable): Observable;
catch(second: Observable): Observable;
catchException(handler: (exception: Error) => IPromise | Observable): Observable; // alias for catch
catchException(second: Observable): Observable; // alias for catch
combineLatest(second: Observable | IPromise): Observable<[T, T2]>;
combineLatest(
second: Observable | IPromise,
resultSelector: (v1: T, v2: T2) => TResult,
): Observable;
combineLatest(
second: Observable | IPromise,
third: Observable | IPromise,
): Observable<[T, T2, T3]>;
combineLatest(
second: Observable | IPromise,
third: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3) => TResult,
): Observable;
combineLatest(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
): Observable<[T, T2, T3, T4]>;
combineLatest(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult,
): Observable;
combineLatest(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
fifth: Observable | IPromise,
): Observable<[T, T2, T3, T4, T5]>;
combineLatest(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
fifth: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult,
): Observable;
combineLatest(
souces: Array | IPromise>,
resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult,
): Observable;
withLatestFrom(second: Observable | IPromise): Observable<[T, T2]>;
withLatestFrom(
second: Observable | IPromise,
resultSelector: (v1: T, v2: T2) => TResult,
): Observable;
withLatestFrom(
second: Observable | IPromise,
third: Observable | IPromise,
): Observable<[T, T2, T3]>;
withLatestFrom(
second: Observable | IPromise,
third: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3) => TResult,
): Observable;
withLatestFrom(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
): Observable<[T, T2, T3, T4]>;
withLatestFrom(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult,
): Observable;
withLatestFrom(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
fifth: Observable | IPromise,
): Observable<[T, T2, T3, T4, T5]>;
withLatestFrom(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
fifth: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult,
): Observable;
withLatestFrom(
souces: Array | IPromise>,
resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult,
): Observable;
concat(...sources: Array | IPromise>): Observable;
concat(sources: Array | IPromise>): Observable;
concatAll(): T;
concatObservable(): Observable; // alias for concatAll
concatMap(
selector: (value: T, index: number) => Observable,
resultSelector: (value1: T, value2: T2, index: number) => R,
): Observable; // alias for selectConcat
concatMap(
selector: (value: T, index: number) => IPromise,
resultSelector: (value1: T, value2: T2, index: number) => R,
): Observable; // alias for selectConcat
concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat
concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat
concatMap(selector: (value: T, index: number) => R[]): Observable; // alias for selectConcat
concatMap(sequence: Observable): Observable; // alias for selectConcat
concatMap(sequence: R[]): Observable; // alias for selectConcat
merge(maxConcurrent: number): T;
merge(other: Observable): Observable;
merge(other: IPromise): Observable;
mergeAll(): T;
mergeObservable(): T; // alias for mergeAll
skipUntil(other: Observable): Observable;
skipUntil(other: IPromise): Observable;
switch(): T;
switchLatest(): T; // alias for switch
takeUntil(other: Observable): Observable;
takeUntil(other: IPromise): Observable;
zip(second: Observable | IPromise): Observable<[T, T2]>;
zip(
second: Observable | IPromise,
resultSelector: (v1: T, v2: T2) => TResult,
): Observable;
zip(
second: Observable | IPromise,
third: Observable | IPromise,
): Observable<[T, T2, T3]>;
zip(
second: Observable | IPromise,
third: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3) => TResult,
): Observable;
zip(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
): Observable<[T, T2, T3, T4]>;
zip(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult,
): Observable;
zip(
second: Observable | IPromise,
third: Observable | IPromise,
fourth: Observable | IPromise,
fifth: Observable | IPromise,
): Observable<[T, T2, T3, T4, T5]>;
zip(
second: Observable