Turned Observer from class to interfaces.

This commit is contained in:
Igor Oleinikov
2014-03-19 16:42:45 +04:00
parent 4800dc38a7
commit a837a49c69
4 changed files with 20 additions and 13 deletions
+13 -1
View File
@@ -133,7 +133,7 @@ declare module Rx {
// Notifications
export class Notification<T> {
accept(observer: Observer<T>): void;
accept(observer: IObserver<T>): void;
accept<TResult>(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult;
toObservable(scheduler?: IScheduler): Observable<T>;
hasValue: boolean;
@@ -164,6 +164,18 @@ declare module Rx {
onCompleted(): void;
}
export interface Observer<T> extends IObserver<T> {
toNotifier(): (notification: Notification<T>) => void;
asObserver(): Observer<T>;
}
interface ObserverStatic {
create<T>(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer<T>;
fromNotifier<T>(handler: (notification: Notification<T>) => void): Observer<T>;
}
export var Observer: ObserverStatic;
export interface IObservable<T> {
subscribe(observer: Observer<T>): IDisposable;
subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable;
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for RxJS-Async v2.2.15
// Type definitions for RxJS-Async v2.2.17
// Project: http://rx.codeplex.com/
// Definitions by: zoetrope <https://github.com/zoetrope>
// Definitions by: Igor Oleinikov <https://github.com/Igorbek>
+2
View File
@@ -1,6 +1,8 @@
// This file contains common part of defintions for rx.binding.d.ts and rx.lite.d.ts
// Do not include the file separately.
///<reference path="rx-lite.ts"/>
declare module Rx {
export interface BehaviorSubject<T> extends Subject<T> {
}
+4 -11
View File
@@ -48,24 +48,17 @@ declare module Rx {
}
// Observer
export class Observer<T> implements IObserver<T> {
onNext(value: T): void;
onError(exception: any): void;
onCompleted(): void;
toNotifier(): (notification: Notification<T>) =>void;
asObserver(): Observer<T>;
export interface Observer<T> {
checked(): Observer<any>;
}
static create<T>(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer<T>;
static fromNotifier<T>(handler: (notification: Notification<T>) => void): Observer<T>;
interface ObserverStatic {
/**
* Schedules the invocation of observer methods on the given scheduler.
* @param scheduler Scheduler to schedule observer messages on.
* @returns Observer whose messages are scheduled on the given scheduler.
*/
static notifyOn<T>(scheduler: IScheduler): Observer<T>;
notifyOn<T>(scheduler: IScheduler): Observer<T>;
}
export interface Observable<T> {