From 031edca9d22eb54cc25f5d526996c31d95636ffe Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Thu, 5 Oct 2017 21:32:52 -0700 Subject: [PATCH] fix(toPromise): remove lettable version of toPromise toPromise isn't really an "operator", as it does not take an Observable and return an Observable, rather it returns a Promise. This was added mistakenly fixes #2868 --- src/operators/index.ts | 1 - src/operators/toPromise.ts | 61 -------------------------------------- 2 files changed, 62 deletions(-) delete mode 100644 src/operators/toPromise.ts diff --git a/src/operators/index.ts b/src/operators/index.ts index 05f18d607c..e2acc40fb1 100644 --- a/src/operators/index.ts +++ b/src/operators/index.ts @@ -97,7 +97,6 @@ export { timeout } from './timeout'; export { timeoutWith } from './timeoutWith'; export { timestamp } from './timestamp'; export { toArray } from './toArray'; -export { toPromise } from './toPromise'; export { window } from './window'; export { windowCount } from './windowCount'; export { windowTime } from './windowTime'; diff --git a/src/operators/toPromise.ts b/src/operators/toPromise.ts deleted file mode 100644 index ffd6ea5b8d..0000000000 --- a/src/operators/toPromise.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Observable } from '../Observable'; -import { UnaryFunction } from '../interfaces'; - -/* tslint:disable:max-line-length */ -export function toPromise(): UnaryFunction, Promise>; -export function toPromise(PromiseCtor: typeof Promise): UnaryFunction, Promise>; -export function toPromise(PromiseCtor: PromiseConstructorLike): UnaryFunction, Promise>; -/* tslint:enable:max-line-length */ - -/** - * Converts an Observable sequence to a ES2015 compliant promise. - * - * @example - * // Using normal ES2015 - * let source = Rx.Observable - * .of(42) - * .toPromise(); - * - * source.then((value) => console.log('Value: %s', value)); - * // => Value: 42 - * - * // Rejected Promise - * // Using normal ES2015 - * let source = Rx.Observable - * .throw(new Error('woops')) - * .toPromise(); - * - * source - * .then((value) => console.log('Value: %s', value)) - * .catch((err) => console.log('Error: %s', err)); - * // => Error: Error: woops - * - * // Setting via the config - * Rx.config.Promise = RSVP.Promise; - * - * let source = Rx.Observable - * .of(42) - * .toPromise(); - * - * source.then((value) => console.log('Value: %s', value)); - * // => Value: 42 - * - * // Setting via the method - * let source = Rx.Observable - * .of(42) - * .toPromise(RSVP.Promise); - * - * source.then((value) => console.log('Value: %s', value)); - * // => Value: 42 - * - * @param {PromiseConstructor} [PromiseCtor] The constructor of the promise. If not provided, - * it will look for a constructor first in Rx.config.Promise then fall back to - * the native Promise constructor if available. - * @return {Promise} An ES2015 compatible promise with the last value from - * the observable sequence. - * @method toPromise - * @owner Observable - */ -export function toPromise(PromiseCtor?: PromiseConstructorLike): UnaryFunction, Promise> { - return (source: Observable) => source.toPromise(); -}