From f0946ebcda4f0f311d71ad46831fbaac95695351 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Sun, 2 Feb 2014 13:42:57 +0400 Subject: [PATCH 1/4] rx.js: updated to version 2.2.13 --- rx.js/rx.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rx.js/rx.d.ts b/rx.js/rx.d.ts index f055452e3..949baa68e 100644 --- a/rx.js/rx.d.ts +++ b/rx.js/rx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS +// Type definitions for RxJS v2.2.13 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Revision by: Igor Oleinikov @@ -167,7 +167,6 @@ declare module Rx { // Current Thread IScheduler interface ICurrentThreadScheduler extends IScheduler { scheduleRequired(): boolean; - ensureTrampoline(action: () =>IDisposable): IDisposable; } // Notifications From 87cd95fd92bf2adb426271938ede6fe42b8df4f4 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Fri, 7 Mar 2014 14:07:28 +0400 Subject: [PATCH 2/4] promises-a-plus: added initial defintions rx.js: modified IPromise in Async module to match Promises/A+ --- promises-a-plus/promises-a-plus-tests.ts | 41 ++++++++++++++++++++++++ promises-a-plus/promises-a-plus.d.ts | 16 +++++++++ rx.js/rx.async.d.ts | 6 ++-- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 promises-a-plus/promises-a-plus-tests.ts create mode 100644 promises-a-plus/promises-a-plus.d.ts diff --git a/promises-a-plus/promises-a-plus-tests.ts b/promises-a-plus/promises-a-plus-tests.ts new file mode 100644 index 000000000..5b10b1b6e --- /dev/null +++ b/promises-a-plus/promises-a-plus-tests.ts @@ -0,0 +1,41 @@ +/// +/// + +var thenNum: PromisesAPlus.Thenable; +var thenStr: PromisesAPlus.Thenable; +var thenBool: PromisesAPlus.Thenable; + +var impl: PromisesAPlus.PromiseImpl; + +declare class PromiseImpl { + constructor(resolver: (resolvePromise: (value: R) => void, rejectPromise: (reason: any) => void) => void); + + then(onFulfill: (value: R) => PromiseImpl, onReject: (error: any) => PromiseImpl): PromiseImpl; + then(onFulfill: (value: R) => PromiseImpl, onReject?: (error: any) => U): PromiseImpl; + then(onFulfill: (value: R) => U, onReject: (error: any) => PromiseImpl): PromiseImpl; + then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): PromiseImpl; +} + +function testCompatibleWithPromiseImpl() { + var pNum: PromiseImpl = thenNum; + + thenNum = pNum; + + impl = PromiseImpl; +} + +function testCompatibleWithRxJS() { + // from spec to Rx + var rxThenNum: Rx.IPromise = thenNum; + var rxThenStr: Rx.IPromise = thenStr; + + // from Rx to spec + thenNum = rxThenNum; + thenStr = rxThenStr; + + var obsNum: Rx.Observable; + + thenNum = obsNum.toPromise>(impl); + thenNum = obsNum.toPromise(impl); + obsNum.toPromise(PromiseImpl); +} diff --git a/promises-a-plus/promises-a-plus.d.ts b/promises-a-plus/promises-a-plus.d.ts new file mode 100644 index 000000000..7a3bee776 --- /dev/null +++ b/promises-a-plus/promises-a-plus.d.ts @@ -0,0 +1,16 @@ +declare module PromisesAPlus { + interface PromiseCtor { + (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; + } + + interface PromiseImpl { + new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; + } + + interface Thenable { + then(onFulfill: (value: R) => Thenable, onReject: (error: any) => Thenable): Thenable; + then(onFulfill: (value: R) => Thenable, onReject?: (error: any) => U): Thenable; + then(onFulfill: (value: R) => U, onReject: (error: any) => Thenable): Thenable; + then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): Thenable; + } +} diff --git a/rx.js/rx.async.d.ts b/rx.js/rx.async.d.ts index cdd93b9a8..7238acafb 100644 --- a/rx.js/rx.async.d.ts +++ b/rx.js/rx.async.d.ts @@ -104,9 +104,9 @@ declare module Rx { * Promise A+ */ export interface IPromise { - then(onFulfilled?: (value: T) => IPromise, onRejected?: (reason: any) => IPromise): IPromise; - then(onFulfilled?: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; - then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => IPromise): IPromise; + then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise; + then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; + then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise; then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise; } } From 207d7d0faca60a073d8dcc8c981eedddf9e2879a Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 10 Mar 2014 21:26:58 +0400 Subject: [PATCH 3/4] promises-a-plus: updated tests of compatibility with implementation libraries --- promises-a-plus/promises-a-plus-tests.ts | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/promises-a-plus/promises-a-plus-tests.ts b/promises-a-plus/promises-a-plus-tests.ts index 5b10b1b6e..5ae93113a 100644 --- a/promises-a-plus/promises-a-plus-tests.ts +++ b/promises-a-plus/promises-a-plus-tests.ts @@ -1,5 +1,8 @@ /// /// +/// +/// +/// var thenNum: PromisesAPlus.Thenable; var thenStr: PromisesAPlus.Thenable; @@ -35,7 +38,44 @@ function testCompatibleWithRxJS() { var obsNum: Rx.Observable; + // implementation usage thenNum = obsNum.toPromise>(impl); thenNum = obsNum.toPromise(impl); obsNum.toPromise(PromiseImpl); } + +function testCompatibleWithES6Promises() { + // from spec to ES6 + var es6ThenNum: Thenable = thenNum; + var es6ThenStr: Thenable = thenStr; + + // from ES6 to spec + thenNum = es6ThenNum; + thenStr = es6ThenStr; + + // implementation + impl = Promise; +} + +function testCompatibleWithQ() { + // from spec to ES6 + var qThenNum: Q.IPromise = thenNum; + var qThenStr: Q.IPromise = thenStr; + + // from ES6 to spec + thenNum = qThenNum; + thenStr = qThenStr; + + // there's no standart implementation with constructor behaviour +} + +function testCompatibleWithWhen() { + var whenPromiseNum: When.Promise; + var whenPromiseStr: When.Promise; + + // from ES6 to spec + thenNum = whenPromiseNum; + thenStr = whenPromiseStr; + + // there's no standart implementation with constructor behaviour +} From c0faaf0ebc278b3c3feae8cc63b1b5570303296f Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 10 Mar 2014 21:43:25 +0400 Subject: [PATCH 4/4] promises-a-plus: fixed Q import casing in tests --- promises-a-plus/promises-a-plus-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promises-a-plus/promises-a-plus-tests.ts b/promises-a-plus/promises-a-plus-tests.ts index 5ae93113a..fa1453645 100644 --- a/promises-a-plus/promises-a-plus-tests.ts +++ b/promises-a-plus/promises-a-plus-tests.ts @@ -1,7 +1,7 @@ /// /// /// -/// +/// /// var thenNum: PromisesAPlus.Thenable;