Comparing version 1.1.1 to 1.1.2
@@ -160,3 +160,2 @@ "use strict"; | ||
this.emitter.removeAllListeners(); | ||
this.emitter = null; | ||
}; | ||
@@ -163,0 +162,0 @@ return Broadcaster; |
@@ -79,3 +79,3 @@ "use strict"; | ||
if (typeof topic !== 'undefined') { | ||
this.topics[name] = null; | ||
this.topics[name] = undefined; | ||
topic.destroy(); | ||
@@ -92,3 +92,3 @@ return true; | ||
Channel.prototype._onTopicDestroyed = function (name) { | ||
this.topics[name] = null; | ||
this.topics[name] = undefined; | ||
}; | ||
@@ -103,3 +103,2 @@ /** | ||
} | ||
this.topics = null; | ||
this.emitter.emit('channel_destroyed', this.name); | ||
@@ -106,0 +105,0 @@ _super.prototype.destroy.call(this); |
@@ -107,3 +107,3 @@ "use strict"; | ||
EventBus.prototype.onChannelDestroyed = function (name) { | ||
this.channels[name] = null; | ||
this.channels[name] = undefined; | ||
}; | ||
@@ -119,3 +119,2 @@ /** | ||
} | ||
this.channels = null; | ||
}; | ||
@@ -122,0 +121,0 @@ return EventBus; |
{ | ||
"name": "estacion", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Event bus implementation made on top of native node events module", | ||
@@ -21,3 +21,3 @@ "main": "lib", | ||
"clean": "del lib", | ||
"docs": "del docs && typedoc --theme markdown --readme none --excludePrivate --out docs/api ./src", | ||
"docs": "del docs && typedoc --theme markdown --readme none --excludePrivate --excludeNotExported --out docs/api ./src", | ||
"compile": "npm run clean && tsc --tsBuildInfoFile ./.buildcache/lib.tsbuildinfo" | ||
@@ -24,0 +24,0 @@ }, |
@@ -320,3 +320,3 @@ # Estacion | ||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details | ||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details | ||
@@ -323,0 +323,0 @@ ##### Acknowledgments |
import { EventEmitter } from 'events' | ||
type ListenerProxy = keyof Pick< | ||
EventEmitter, | ||
| 'addListener' | ||
| 'on' | ||
| 'once' | ||
| 'prependListener' | ||
| 'prependOnceListener' | ||
| 'removeListener' | ||
> | ||
/** | ||
@@ -157,3 +166,3 @@ * Class that represents the parent class for `Channel` and `Topic` classes | ||
private _proxyListener(method: string, listener: Listener): void { | ||
private _proxyListener(method: ListenerProxy, listener: Listener): void { | ||
this.emitter[method](this._name, listener) | ||
@@ -168,3 +177,6 @@ } | ||
private _addListener(method: string, listener: Listener): Subscription { | ||
private _addListener( | ||
method: ListenerProxy, | ||
listener: Listener | ||
): Subscription { | ||
this._proxyListener(method, listener) | ||
@@ -179,3 +191,2 @@ return this._createUnsubscribe(listener) | ||
this.emitter.removeAllListeners() | ||
this.emitter = null | ||
} | ||
@@ -182,0 +193,0 @@ } |
@@ -74,3 +74,3 @@ import { Broadcaster, EventPayload } from './broadcaster' | ||
if (typeof topic !== 'undefined') { | ||
this.topics[name] = null | ||
this.topics[name] = undefined | ||
topic.destroy() | ||
@@ -89,3 +89,3 @@ return true | ||
private _onTopicDestroyed(name: string): void { | ||
this.topics[name] = null | ||
this.topics[name] = undefined | ||
} | ||
@@ -101,3 +101,3 @@ | ||
} | ||
this.topics = null | ||
this.emitter.emit('channel_destroyed', this.name) | ||
@@ -104,0 +104,0 @@ super.destroy() |
@@ -10,3 +10,3 @@ import { Channel } from './channel' | ||
private defaultChannel: Channel | ||
private defaultChannel!: Channel | ||
@@ -122,3 +122,3 @@ private channels: { | ||
private onChannelDestroyed(name: string): void { | ||
this.channels[name] = null | ||
this.channels[name] = undefined | ||
} | ||
@@ -132,6 +132,5 @@ | ||
destroy(): void { | ||
for (var channel in this.channels) { | ||
this.channels[channel].destroy() | ||
for (const channel in this.channels) { | ||
this.channels[channel]!.destroy() | ||
} | ||
this.channels = null | ||
} | ||
@@ -138,0 +137,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1170
57390