Fix Rx.Observable.scan seeded overload

This commit is contained in:
Richard Towers 2015-10-11 19:46:27 +01:00
parent 3fc1377ce2
commit f06966b9ff
2 changed files with 27 additions and 2 deletions

13
rx/rx-lite-tests.ts Normal file
View File

@ -0,0 +1,13 @@
/// <reference path="rx-lite.d.ts" />
function test_scan() {
/* Without a seed */
const source1: Rx.Observable<number> = Rx.Observable.range(1, 3)
.scan((acc, x, i, source) => acc + x);
/* With a seed */
const source2: Rx.Observable<string> = Rx.Observable.range(1, 3)
.scan((acc, x, i, source) => acc + x, '...');
}

16
rx/rx-lite.d.ts vendored
View File

@ -323,8 +323,20 @@ declare module Rx {
materialize(): Observable<Notification<T>>;
repeat(repeatCount?: number): Observable<T>;
retry(retryCount?: number): Observable<T>;
scan<TAcc>(accumulator: (acc: TAcc, value: T, seed: TAcc) => TAcc): Observable<TAcc>;
scan(accumulator: (acc: T, value: T) => T): Observable<T>;
/**
* Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
* For aggregation behavior with no intermediate results, see Observable.aggregate.
* @example
* var res = source.scan(function (acc, x) { return acc + x; });
* var res = source.scan(function (acc, x) { return acc + x; }, 0);
* @param accumulator An accumulator function to be invoked on each element.
* @param seed The initial accumulator value.
* @returns An observable sequence containing the accumulated values.
*/
scan<TAcc>(accumulator: (acc: TAcc, value: T, index?: number, source?: Observable<TAcc>) => TAcc, seed: TAcc): Observable<TAcc>;
scan(accumulator: (acc: T, value: T, index?: number, source?: Observable<T>) => T): Observable<T>;
skipLast(count: number): Observable<T>;
startWith(...values: T[]): Observable<T>;
startWith(scheduler: IScheduler, ...values: T[]): Observable<T>;