Class: abstract Event
Class: abstract
Event
Class representing an Event.
Author
Mr. Stone evensstone@gmail.com
Extended by
Constructors
Constructor
protected new Event(options): Event;
Create an Event.
Parameters
options
The options to create an Event.
Returns
Event
Properties
metadata
readonly metadata: Record<string, unknown>;
The metadata associated with the event.
source?
readonly optional source: object;
The source of the event.
timeStamp
readonly timeStamp: number;
The timestamp of the event creation.
type
readonly type: string;
The type of the event.
Methods
clone()
clone<T>(): T;
Return a cloned instance.
Type Parameters
T
T
extends Event
Returns
T
A cloned instance of the current class.
get()
Get data from metadata.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Call Signature
get<TReturn>(key): undefined | TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
Returns
undefined
| TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Call Signature
get<TReturn>(key, fallback): TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
fallback
TReturn
The fallback value if the key is not found.
Returns
TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
getMetadataValue()
Get data from metadata.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Call Signature
getMetadataValue<TReturn>(key): undefined | TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
Returns
undefined
| TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
Call Signature
getMetadataValue<TReturn>(key, fallback): TReturn;
Get data from metadata.
Type Parameters
TReturn
TReturn
= unknown
Parameters
key
string
The key to retrieve from metadata.
fallback
TReturn
The fallback value if the key is not found.
Returns
TReturn
The value associated with the key or the fallback.
Param
The key to retrieve from metadata.
Param
The fallback value if the key is not found.
is()
is(key, value): boolean;
Check if the given value is equal to the specified value.
Parameters
key
string
The key to check.
value
unknown
The value to compare against.
Returns
boolean
True if the key's value is equal to the specified value, false otherwise.
setMetadataValue()
setMetadataValue(key, value?): this;
Add data to metadata.
Parameters
key
The key or object to add to metadata.
string
| Record
<string
, unknown
>
value?
unknown
The value to associate with the key.
Returns
this
This Event instance.