From d47d1f0994e6e321ec7fb3bf0608659c01c2af45 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Wed, 11 Dec 2013 01:02:56 +0400 Subject: [PATCH 1/2] rx.js: added definition for experimental functions --- rx.js/rx.js.experimental.d.ts | 288 ++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 rx.js/rx.js.experimental.d.ts diff --git a/rx.js/rx.js.experimental.d.ts b/rx.js/rx.js.experimental.d.ts new file mode 100644 index 0000000000..a43788b877 --- /dev/null +++ b/rx.js/rx.js.experimental.d.ts @@ -0,0 +1,288 @@ +// Type definitions for RxJS/Experimental +// Project: https://github.com/Reactive-Extensions/RxJS/ +// Definitions by: Igor Oleinikov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Rx { + + interface IObservable { + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + let(selector: (source: IObservable) => IObservable): IObservable; + + /** + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. + * + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + letBind(selector: (source: IObservable) => IObservable): IObservable; + + /** + * Repeats source as long as condition holds emulating a do while loop. + * @param condition The condition which determines if the source will be repeated. + * @returns An observable sequence which is repeated as long as the condition holds. + */ + doWhile(condition: () => boolean): IObservable; + + /** + * Expands an observable sequence by recursively invoking selector. + * + * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. + * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. + * @returns An observable sequence containing all the elements produced by the recursive expansion. + */ + expand(selector: (item: T) => IObservable, scheduler?: IScheduler): IObservable; + + /** + * Runs two observable sequences in parallel and combines their last elemenets. + * + * @param second Second observable sequence. + * @param resultSelector Result selector function to invoke with the last elements of both sequences. + * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences. + */ + forkJoin(second: IObservable, resultSelector: (left: T, right: TSecond) => TResult): IObservable; + + /** + * Comonadic bind operator. + * @param selector A transform function to apply to each element. + * @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. + * @returns An observable sequence which results from the comonadic bind operation. + */ + manySelect(selector: (item: IObservable, index: number, source: IObservable) => TResult, scheduler?: IScheduler): IObservable; + } + + interface Observable { + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, elseSource: IObservable): IObservable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, scheduler?: IScheduler): IObservable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, elseSource: IObservable): IObservable; + + /** + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: IObservable, scheduler?: IScheduler): IObservable; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => IObservable): IObservable; + + /** + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. + * There is an alias for this method called 'forIn' for browsers (sources: T[], resultSelector: (item: T) => IObservable): IObservable; + + /** + * Repeats source as long as condition holds emulating a while loop. + * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: IObservable): IObservable; + + /** + * Repeats source as long as condition holds emulating a while loop. + * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => string, sources: { [key: string]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, elseSource: IObservable): IObservable; + + /** + * Uses selector to determine which source in sources to use. + * There is an alias 'switchCase' for browsers (selector: () => number, sources: { [key: number]: IObservable; }, scheduler?: IScheduler): IObservable; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * res = Rx.Observable.forkJoin([obs1, obs2]); + * @param sources Array of source sequences. + * @returns An observable sequence with an array collecting the last elements of all the input sequences. + */ + forkJoin(sources: IObservable[]): IObservable; + + /** + * Runs all observable sequences in parallel and collect their last elements. + * + * @example + * res = Rx.Observable.forkJoin(obs1, obs2, ...); + * @param args Source sequences. + * @returns An observable sequence with an array collecting the last elements of all the input sequences. + */ + forkJoin(...args: IObservable[]): IObservable; + } +} From 4dea8bf7d2e8c44f3dfb1d12295d892972f158e7 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Wed, 11 Dec 2013 02:01:37 +0400 Subject: [PATCH 2/2] rx.js: added TS compiler parameters to experimental definitions --- rx.js/rx.js.experimental.d.ts.tscparams | 1 + 1 file changed, 1 insertion(+) create mode 100644 rx.js/rx.js.experimental.d.ts.tscparams diff --git a/rx.js/rx.js.experimental.d.ts.tscparams b/rx.js/rx.js.experimental.d.ts.tscparams new file mode 100644 index 0000000000..e16c76dff8 --- /dev/null +++ b/rx.js/rx.js.experimental.d.ts.tscparams @@ -0,0 +1 @@ +""