ste-core
Version:
Core files for the Strongly Typed Events project.
45 lines (44 loc) • 1.05 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventListBase = void 0;
/**
* Base class for event lists classes. Implements the get and remove.
*
* @export
* @abstract
* @class EventListBaset
* @template TEventDispatcher The type of event dispatcher.
*/
class EventListBase {
constructor() {
this._events = {};
}
/**
* Gets the dispatcher associated with the name.
*
* @param {string} name The name of the event.
* @returns {TEventDispatcher} The disptacher.
*
* @memberOf EventListBase
*/
get(name) {
let event = this._events[name];
if (event) {
return event;
}
event = this.createDispatcher();
this._events[name] = event;
return event;
}
/**
* Removes the dispatcher associated with the name.
*
* @param {string} name
*
* @memberOf EventListBase
*/
remove(name) {
delete this._events[name];
}
}
exports.EventListBase = EventListBase;
;