# Hooks Class

Module
import { Hooks } from "@tsed/core"
Source/packages/core/src/class/Hooks.ts

# Overview

class Hooks {
/**
 * Listen a hook event
 * @param event
 * @param cb
 */
<span class="token function">on</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> cb<span class="token punctuation">:</span> Function<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
/**
 * Remove a listener attached to an event
 * @param event
 * @param cb
 */
<span class="token function">off</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> cb<span class="token punctuation">:</span> Function<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
/**
 * Trigger an event and call listener.
 * @param event
 * @param args
 * @param callThis
 */
<span class="token function">emit</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> args?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> callThis?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>
/**
 * Trigger an event<span class="token punctuation">,</span> listener alter given value and return it.
 * @param event
 * @param value
 * @param args
 * @param callThis
 */
<span class="token function">alter</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> value<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> args?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> callThis?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
/**
 * Trigger an event and call async listener.
 * @param event
 * @param args
 * @param callThis
 */
<span class="token function">asyncEmit</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> args?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> callThis?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Promise&lt;<span class="token keyword">void</span>&gt;<span class="token punctuation">;</span>
/**
 * Trigger an event<span class="token punctuation">,</span> async listener alter given value and return it.
 * @param event
 * @param value
 * @param args
 * @param callThis
 */
<span class="token function">asyncAlter</span><span class="token punctuation">(</span>event<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> value<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">,</span> args?<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span> callThis?<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> Promise&lt;<span class="token keyword">any</span>&gt;<span class="token punctuation">;</span>

}