@react-form-builder/core
Version:
React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required
43 lines (42 loc) • 1.04 kB
JavaScript
class i {
handlers = [];
/**
* Adds a handler to the list of subscribers.
* @param handler the handler function to be added.
*/
subscribe(s) {
this.handlers.push(s);
}
/**
* Removes the specified event handler from the list of handlers.
* @param handler the event handler to remove.
*/
unsubscribe(s) {
this.handlers = this.handlers.filter((e) => e !== s);
}
/**
* Returns true if the object has subscribers, false otherwise.
* @returns true if the object has handlers registered for events, otherwise returns false.
*/
get isSubscribed() {
return this.handlers.length > 0;
}
/**
* Invokes the event by calling all registered event handlers.
* @param sender the sender of the event.
* @param eventArgs the event arguments.
*/
invoke(s, e) {
[...this.handlers].forEach((h) => h(s, e));
}
/**
* Dispose method to release all handlers.
*/
dispose() {
this.handlers = [];
}
}
export {
i as SyncEvent
};
//# sourceMappingURL=SyncEvent.js.map