Class: NexoEvent<Target, Data>
Defined in: src/events/NexoEvent.ts:15
Represents an event with additional properties and methods for managing event behavior. This class allows for the specification of event data and target and provides functionality to prevent the default behavior of an event if it is cancelable.
Example
const event = new NexoEvent('proxy', { data: { message: 'New proxy created!' }, cancelable: true });
event.preventDefault();
Extended by
Type Parameters
• Target = unknown
The type of the event's target (default: unknown
).
• Data = unknown
The type of data associated with the event (default: unknown
).
Constructors
new NexoEvent()
new NexoEvent<
Target
,Data
>(name
,options
):NexoEvent
<Target
,Data
>
Defined in: src/events/NexoEvent.ts:49
Creates an instance of the NexoEvent
.
Parameters
name
string
The name of the event.
options
Event
<Target
, Data
> = {}
Options to configure the event (e.g., data
, target
, cancelable
).
Returns
NexoEvent
<Target
, Data
>
Example
const event = new NexoEvent('proxy', { data: { message: 'New proxy created!' }, cancelable: true });
Properties
cancelable
readonly
cancelable:boolean
Defined in: src/events/NexoEvent.ts:29
Indicates whether the event is cancelable.
data
readonly
data:Data
Defined in: src/events/NexoEvent.ts:20
The data associated with the event.
name
readonly
name:string
Defined in: src/events/NexoEvent.ts:17
The name of the event.
returnValue
returnValue:
unknown
Defined in: src/events/NexoEvent.ts:32
The value to be returned by the event after it has been processed.
target
readonly
target:Target
Defined in: src/events/NexoEvent.ts:23
The target to which the event is dispatched.
timestamp
readonly
timestamp:number
Defined in: src/events/NexoEvent.ts:26
The timestamp indicating when the event was created.
Accessors
defaultPrevented
Get Signature
get defaultPrevented():
boolean
Defined in: src/events/NexoEvent.ts:87
Gets whether the default behavior of the event has been prevented.
Example
const event = new NexoEvent('proxy', { cancelable: true });
event.preventDefault();
console.log(event.defaultPrevented); // true
Returns
boolean
true
if the default behavior has been prevented; otherwise false
.
Methods
preventDefault()
preventDefault():
void
Defined in: src/events/NexoEvent.ts:69
Prevents the default behavior of the event if it is cancelable.
Returns
void
Remarks
If the event is not cancelable, this method has no effect.
Example
const event = new NexoEvent('proxy', { cancelable: true });
event.preventDefault(); // Prevents the default behavior