@4players/odin
Version:
A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects
36 lines (35 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OdinEventTarget = exports.OdinEvent = void 0;
/**
* Custom Event providing Odin Event Payload of a provided type.
*/
class OdinEvent extends Event {
constructor(type, payload) {
super(type);
this.payload = payload;
}
}
exports.OdinEvent = OdinEvent;
/**
* A generic event target class designed for strongly-typed event handling.
* OdinEventTarget extends the functionality of the standard EventTarget to allow
* interactions with predefined event types and handlers.
*
* @template Events The mapping of event type names to handler callback signatures.
*/
class OdinEventTarget {
constructor() {
this._eventTarget = new EventTarget();
}
addEventListener(eventName, handler, options) {
this._eventTarget.addEventListener(eventName, handler, options);
}
dispatchEvent(event) {
this._eventTarget.dispatchEvent(event);
}
removeEventListener(type, callback) {
this._eventTarget.removeEventListener(type, callback);
}
}
exports.OdinEventTarget = OdinEventTarget;