vim-webgl-component
Version:
A demonstration app built on top of the vim-webgl-viewer
62 lines (61 loc) • 1.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleEventDispatcher = void 0;
const ste_core_1 = require("ste-core");
/**
* The dispatcher handles the storage of subsciptions and facilitates
* subscription, unsubscription and dispatching of a simple event
*
* @export
* @class SimpleEventDispatcher
* @extends {DispatcherBase<ISimpleEventHandler<TArgs>>}
* @implements {ISimpleEvent<TArgs>}
* @template TArgs
*/
class SimpleEventDispatcher extends ste_core_1.DispatcherBase {
/**
* Creates an instance of SimpleEventDispatcher.
*
* @memberOf SimpleEventDispatcher
*/
constructor() {
super();
}
/**
* Dispatches the event.
*
* @param {TArgs} args The arguments object.
* @returns {IPropagationStatus} The status of the event.
*
* @memberOf SimpleEventDispatcher
*/
dispatch(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 without waiting for the result.
*
* @param {TArgs} args The arguments object.
*
* @memberOf SimpleEventDispatcher
*/
dispatchAsync(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 {ISimpleEvent<TArgs>} The event.
*
* @memberOf SimpleEventDispatcher
*/
asEvent() {
return super.asEvent();
}
}
exports.SimpleEventDispatcher = SimpleEventDispatcher;