Function: Emit()
function Emit(options?: EmitOptions): <This, Return>(target: (this: This, ...args: any[]) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: any[]) => Return>) => void;
Defined in: src/events-handler/decorators/emit.ts:32
Parameters
| Parameter | Type |
|---|---|
options |
EmitOptions |
Returns
<This, Return>(target: (this: This, ...args: any[]) => Return, context: ClassMethodDecoratorContext<This, (this: This, ...args: any[]) => Return>): void;
Type Parameters
| Type Parameter |
|---|
This extends HTMLElement |
Return |
Parameters
| Parameter | Type |
|---|---|
target |
(this: This, …args: any[]) => Return |
context |
ClassMethodDecoratorContext<This, (this: This, …args: any[]) => Return> |
Returns
void
Emit
es un decorador para métodos que automáticamente convierte su valor de retorno en un CustomEvent que se despacha desde el componente.
Ejemplo de uso:
Emit
onUserSelect() { return { name: this.name, id: this.id }; }
Esto automáticamente:
- Crea un CustomEvent llamado ‘userselect’
- Coloca el objeto retornado en event.detail
- Despacha el evento desde el elemento del componente