UNPKG

vim-webgl-component

Version:

A demonstration app built on top of the vim-webgl-viewer

65 lines (64 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventDispatcher = void 0; const ste_core_1 = require("ste-core"); /** * Dispatcher implementation for events. Can be used to subscribe, unsubscribe * or dispatch events. Use the ToEvent() method to expose the event. * * @export * @class EventDispatcher * @extends {DispatcherBase<IEventHandler<TSender, TArgs>>} * @implements {IEvent<TSender, TArgs>} * @template TSender The sender type. * @template TArgs The event arguments type. */ class EventDispatcher extends ste_core_1.DispatcherBase { /** * Creates an instance of EventDispatcher. * * @memberOf EventDispatcher */ constructor() { super(); } /** * Dispatches the event. * * @param {TSender} sender The sender. * @param {TArgs} args The arguments. * @returns {IPropagationStatus} The propagation status to interact with the event * * @memberOf EventDispatcher */ dispatch(sender, args) { const result = this._dispatch(false, this, arguments); if (result == null) { throw new ste_core_1.DispatchError("Got `null` back from dispatch."); } return result; } /** * Dispatches the event in an async way. Does not support event interaction. * * @param {TSender} sender The sender. * @param {TArgs} args The arguments. * * @memberOf EventDispatcher */ dispatchAsync(sender, args) { this._dispatch(true, this, arguments); } /** * Creates an event from the dispatcher. Will return the dispatcher * in a wrapper. This will prevent exposure of any dispatcher methods. * * @returns {IEvent<TSender, TArgs>} The event. * * @memberOf EventDispatcher */ asEvent() { return super.asEvent(); } } exports.EventDispatcher = EventDispatcher;