From a837a49c6920a792412de652c3d5b834a12a8c4b Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Wed, 19 Mar 2014 16:42:45 +0400 Subject: [PATCH] Turned `Observer` from class to interfaces. --- rx.js/rx-lite.ts | 14 +++++++++++++- rx.js/rx.async.d.ts | 2 +- rx.js/rx.binding-lite.ts | 2 ++ rx.js/rx.d.ts | 15 ++++----------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/rx.js/rx-lite.ts b/rx.js/rx-lite.ts index 0c1391c41..1e387af48 100644 --- a/rx.js/rx-lite.ts +++ b/rx.js/rx-lite.ts @@ -133,7 +133,7 @@ declare module Rx { // Notifications export class Notification { - accept(observer: Observer): void; + accept(observer: IObserver): void; accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult; toObservable(scheduler?: IScheduler): Observable; hasValue: boolean; @@ -164,6 +164,18 @@ declare module Rx { onCompleted(): void; } + export interface Observer extends IObserver { + toNotifier(): (notification: Notification) => void; + asObserver(): Observer; + } + + interface ObserverStatic { + create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; + fromNotifier(handler: (notification: Notification) => void): Observer; + } + + export var Observer: ObserverStatic; + export interface IObservable { subscribe(observer: Observer): IDisposable; subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; diff --git a/rx.js/rx.async.d.ts b/rx.js/rx.async.d.ts index 45bf45236..b24191ae4 100644 --- a/rx.js/rx.async.d.ts +++ b/rx.js/rx.async.d.ts @@ -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 // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.binding-lite.ts b/rx.js/rx.binding-lite.ts index 1ce2b00b9..fa1098368 100644 --- a/rx.js/rx.binding-lite.ts +++ b/rx.js/rx.binding-lite.ts @@ -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. +/// + declare module Rx { export interface BehaviorSubject extends Subject { } diff --git a/rx.js/rx.d.ts b/rx.js/rx.d.ts index 2cf1d38b8..7b3e1c073 100644 --- a/rx.js/rx.d.ts +++ b/rx.js/rx.d.ts @@ -48,24 +48,17 @@ declare module Rx { } // Observer - export class Observer implements IObserver { - onNext(value: T): void; - onError(exception: any): void; - onCompleted(): void; - - toNotifier(): (notification: Notification) =>void; - asObserver(): Observer; + export interface Observer { checked(): Observer; + } - static create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; - static fromNotifier(handler: (notification: Notification) => void): Observer; - + 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(scheduler: IScheduler): Observer; + notifyOn(scheduler: IScheduler): Observer; } export interface Observable {