to(channel) { if (StringMapWrapper.contains(this._channels, channel)) { return this._channels[channel]; } else { var emitter = new EventEmitter(); emitter.observer({ next: (message) => { this._postMessageTarget.postMessage({ channel: channel, message: message }); } }); return emitter; } }
PostMessageBusSink.prototype.to = function (channel) { var _this = this; if (collection_1.StringMapWrapper.contains(this._channels, channel)) { return this._channels[channel]; } else { var emitter = new async_1.EventEmitter(); emitter.observer({ next: function (message) { _this._postMessageTarget.postMessage({ channel: channel, message: message }); } }); return emitter; } };
onEnter: () => { // console.log('ZONE.enter', this._nesting, this._isStable); this._nesting++; if (this._isStable) { this._isStable = false; this._onUnstable.emit(null); } },
initChannel(channel, runInZone = true) { if (StringMapWrapper.contains(this._channels, channel)) { throw new BaseException(`${channel} has already been initialized`); } var emitter = new EventEmitter(false); var channelInfo = new _Channel(emitter, runInZone); this._channels[channel] = channelInfo; emitter.subscribe((data) => { var message = { channel: channel, message: data }; if (runInZone) { this._messageBuffer.push(message); } else { this._sendMessages([message]); } }); }
return this._componentRef.then((componentRef) => { this.activateEvents.emit(componentRef.instance); if (hasLifecycleHook(hookMod.routerOnActivate, componentType)) { return this._componentRef.then((ref) => ref.instance.routerOnActivate(nextInstruction, previousInstruction)); } else { return componentRef; } });
PostMessageBusSink.prototype.initChannel = function (channel, runInZone) { var _this = this; if (runInZone === void 0) { runInZone = true; } if (collection_1.StringMapWrapper.contains(this._channels, channel)) { throw new exceptions_1.BaseException(channel + " has already been initialized"); } var emitter = new async_1.EventEmitter(false); var channelInfo = new _Channel(emitter, runInZone); this._channels[channel] = channelInfo; emitter.subscribe(function (data) { var message = { channel: channel, message: data }; if (runInZone) { _this._messageBuffer.push(message); } else { _this._sendMessages([message]); } }); };
_checkStable() { if (this._nesting == 0) { if (!this._hasPendingMicrotasks && !this._isStable) { try { // console.log('ZONE.microtaskEmpty'); this._nesting++; this._onMicrotaskEmpty.emit(null); } finally { this._nesting--; if (!this._hasPendingMicrotasks) { try { // console.log('ZONE.stable', this._nesting, this._isStable); this.runOutsideAngular(() => this._onStable.emit(null)); } finally { this._isStable = true; } } } } } }
/** @internal */ notifyOnChanges() { this._emitter.emit(this); }
this.runOutsideAngular(() => { this._onEventDoneEvents.emit(null); });
parentRun.call(this._innerZone, () => { this._onTurnDoneEvents.emit(null); });
this.runOutsideAngular(() => this._onStable.emit(null));
onError: (error) => this._onErrorEvents.emit(error)