UNPKG

@reactivex/rxjs

Version:

Reactive Extensions for modern JavaScript

29 lines 1.01 kB
define(["require", "exports", '../util/root'], function (require, exports, root_1) { "use strict"; /** * @param PromiseCtor * @return {Promise<T>} * @method toPromise * @owner Observable */ function toPromise(PromiseCtor) { var _this = this; if (!PromiseCtor) { if (root_1.root.Rx && root_1.root.Rx.config && root_1.root.Rx.config.Promise) { PromiseCtor = root_1.root.Rx.config.Promise; } else if (root_1.root.Promise) { PromiseCtor = root_1.root.Promise; } } if (!PromiseCtor) { throw new Error('no Promise impl found'); } return new PromiseCtor(function (resolve, reject) { var value; _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); }); }); } exports.toPromise = toPromise; }); //# sourceMappingURL=toPromise.js.map