feat(zen-observable): add concat method typing

Adding missing method concat as shown here https://github.com/zenparsing/zen-observable.
Concat merges the current observable with additional observables.
This commit is contained in:
Thomas Truong 2018-06-12 14:18:43 +01:00
parent 250d7e5942
commit b970fb4aba
2 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,8 @@
// Type definitions for zen-observable 0.5
// Type definitions for zen-observable 0.8
// Project: https://github.com/zenparsing/zen-observable
// Definitions by: Kombu <https://github.com/aicest>
// JounQin <https://github.com/JounQin>
// Thomas <https://github.com/itomtom>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare global {
@ -52,6 +53,7 @@ declare class Observable<T> {
reduce(callback: (previousValue: T, currentValue: T) => T, initialValue?: T): Observable<T>;
reduce<R>(callback: (previousValue: R, currentValue: T) => R, initialValue?: R): Observable<R>;
flatMap<R>(callback: (value: T) => ZenObservable.ObservableLike<R>): Observable<R>;
concat<R>(...observable: Array<Observable<R>>): Observable<R>;
static from<R>(observable: Observable<R> | ZenObservable.ObservableLike<R> | ArrayLike<R>): Observable<R>;
static of<R>(...items: R[]): Observable<R>;

View File

@ -94,6 +94,14 @@ Observable.of(1, 2, 3)
.flatMap(val => Observable.of(val.toString()))
.subscribe(val => assert(typeof val === 'string'));
/**
* observable.concat
*/
Observable.of(1, 2, 3)
.concat(Observable.of(4, 5, 6), Observable.of(7, 8, 9))
.subscribe(val => assert(typeof val === 'number'));
/**
* ZenObservable
*/