webcomponent: update event handling methods to use WebComponentEvent type for better type safety
This commit is contained in:
parent
7a81873285
commit
af3697f94c
@ -48,7 +48,7 @@ export class CommandsManager {
|
||||
* @param callback Function to be called when the event is triggered
|
||||
* @returns The component instance for chaining
|
||||
*/
|
||||
public on(element: HTMLElement, eventName: string, callback: (detail: any) => void): this {
|
||||
public on(element: HTMLElement, eventName: WebComponentEvent, callback: (detail: any) => void): this {
|
||||
if (!(Object.values(WebComponentEvent) as string[]).includes(eventName)) {
|
||||
console.warn(`Event "${eventName}" is not supported.`);
|
||||
return this;
|
||||
@ -83,7 +83,7 @@ export class CommandsManager {
|
||||
* @param callback Function to be called when the event is triggered
|
||||
* @returns The component instance for chaining
|
||||
*/
|
||||
public once(element: HTMLElement, eventName: string, callback: (detail: any) => void): this {
|
||||
public once(element: HTMLElement, eventName: WebComponentEvent, callback: (detail: any) => void): this {
|
||||
if (!(Object.values(WebComponentEvent) as string[]).includes(eventName)) {
|
||||
console.warn(`Event "${eventName}" is not supported.`);
|
||||
return this;
|
||||
@ -108,7 +108,7 @@ export class CommandsManager {
|
||||
* @param callback Optional callback to remove (if not provided, removes all handlers for this event)
|
||||
* @returns The component instance for chaining
|
||||
*/
|
||||
public off(element: HTMLElement, eventName: string, callback?: (detail: any) => void): this {
|
||||
public off(element: HTMLElement, eventName: WebComponentEvent, callback?: (detail: any) => void): this {
|
||||
if (!callback) {
|
||||
// Remove all handlers for this event
|
||||
const handlers = this.eventHandlers.get(eventName);
|
||||
|
||||
@ -174,7 +174,7 @@ export class OpenViduMeet extends HTMLElement {
|
||||
* @param callback Function to be called when the event is triggered
|
||||
* @returns The component instance for chaining
|
||||
*/
|
||||
public on(eventName: string, callback: (detail: any) => void): this {
|
||||
public on(eventName: WebComponentEvent, callback: (detail: any) => void): this {
|
||||
this.commandsManager.on(this, eventName, callback);
|
||||
return this;
|
||||
}
|
||||
@ -185,7 +185,7 @@ export class OpenViduMeet extends HTMLElement {
|
||||
* @param callback Function to be called when the event is triggered
|
||||
* @returns The component instance for chaining
|
||||
*/
|
||||
public once(eventName: string, callback: (detail: any) => void): this {
|
||||
public once(eventName: WebComponentEvent, callback: (detail: any) => void): this {
|
||||
this.commandsManager.once(this, eventName, callback);
|
||||
return this;
|
||||
}
|
||||
@ -196,7 +196,7 @@ export class OpenViduMeet extends HTMLElement {
|
||||
* @param callback Optional callback to remove (if not provided, removes all handlers for this event)
|
||||
* @returns The component instance for chaining
|
||||
*/
|
||||
public off(eventName: string, callback?: (detail: any) => void): this {
|
||||
public off(eventName: WebComponentEvent, callback?: (detail: any) => void): this {
|
||||
this.commandsManager.off(this, eventName, callback);
|
||||
return this;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user