UNPKG

jw-ng-forward

Version:

Temporary package. The default solution for those that want to write Angular 2.x style code in Angular 1.x

64 lines (63 loc) 3.01 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var rxjs_1 = require("rxjs"); var EventEmitter = (function (_super) { __extends(EventEmitter, _super); function EventEmitter(isAsync) { if (isAsync === void 0) { isAsync = true; } var _this = _super.call(this) || this; _this.__isAsync = isAsync; return _this; } EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); }; EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) { var schedulerFn; var errorFn = function (err) { return null; }; var completeFn = function () { return null; }; if (generatorOrNext && typeof generatorOrNext === 'object') { schedulerFn = this.__isAsync ? function (value) { setTimeout(function () { return generatorOrNext.next(value); }); } : function (value) { generatorOrNext.next(value); }; if (generatorOrNext.error) { errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } : function (err) { generatorOrNext.error(err); }; } if (generatorOrNext.complete) { completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } : function () { generatorOrNext.complete(); }; } } else { schedulerFn = this.__isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } : function (value) { generatorOrNext(value); }; if (error) { errorFn = this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); }; } if (complete) { completeFn = this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); }; } } var sink = _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn); if (generatorOrNext instanceof rxjs_1.Subscription) { generatorOrNext.add(sink); } return sink; }; return EventEmitter; }(rxjs_1.Subject)); exports.EventEmitter = EventEmitter;