Last active
March 23, 2017 12:41
-
-
Save typoerr/64c4520fcfff7926c991a2b9c3c47b56 to your computer and use it in GitHub Desktop.
zen-observable.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'zen-observable' { | |
export = Observable; | |
class Observable<T> { | |
constructor(subscriber: SubscriberFunction<T>); | |
subscribe(observer: Observer<T>): Subscription; | |
subscribe(observer: (value: T) => any): Subscription; | |
forEach(callback: (value: T) => any): Promise<void>; | |
map<U>(callback: (value: T) => U): Observable<U>; | |
filter(callback: (value: T) => boolean): Observable<T>; | |
reduce<U>(callback: (previousValue: T, currentValue: T) => U, initialValue?: T): Observable<U>; | |
reduce<U, V>(callback: (previousValue: V, currentValue: T) => U, initialValue: V): Observable<U>; | |
flatMap<U>(callback: (value: T) => Observable<U>): Observable<U> | |
static of<T>(...item: T[]): Observable<T>; | |
static from<T>(observable: Observable<T> | T[]): Observable<T>; | |
} | |
interface SubscriberFunction<T> { | |
(subscriptionObserver: SubscriptionObserver<T>): (() => void) | Subscription; | |
} | |
interface SubscriptionObserver<T> { | |
next(value: T): void; | |
error(error: Error): void; | |
complete(): void; | |
readonly closed: boolean; | |
} | |
interface Observer<T> { | |
start?(subscription: Subscription): void; | |
next?(value: T): void; | |
error?(error: Error): void; | |
complete?(): void; | |
} | |
interface Subscription { | |
unsubscribe(): void; | |
readonly closed: boolean | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment