AsyncEvent<T>
Simple event handler by Jason Kleban. Keep in mind that if you want to remove it later, you might want to declare the callback as an object. If you want to maintain the reference to this
, you will need to declare the callback as an arrow function.
Type parameters
Type parameter |
---|
T |
Properties
enabled
enabled:
boolean
=true
Whether this event is active or not. If not, it won't trigger.
Methods
add()
add(
handler
):void
Add a callback to this event instance.
Parameters
Parameter | Type | Description |
---|---|---|
handler | T extends void ? () => Promise <void > : (data ) => Promise <void > | the callback to be added to this event. |
Returns
void
remove()
remove(
handler
):void
Removes a callback from this event instance.
Parameters
Parameter | Type | Description |
---|---|---|
handler | T extends void ? () => Promise <void > : (data ) => Promise <void > | the callback to be removed from this event. |
Returns
void
reset()
reset():
void
Gets rid of all the suscribed events.
Returns
void
trigger()
trigger(
data
?):Promise
<void
>
Triggers all the callbacks assigned to this event.
Parameters
Parameter | Type |
---|---|
data ? | T |
Returns
Promise
<void
>