Skip to main content
Version: v3.0.0

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).

Implements

  • NexoEvent<Target, Data>

Constructors

new NexoEvent()

new NexoEvent<Target, Data>(name, options): NexoEvent<Target, Data>

Defined in: src/events/NexoEvent.ts:51

Creates an instance of the NexoEvent.

Parameters

name

string

The name of the event.

options

Partial<{ cancelable: boolean; data: Data; target: Target; }> = {}

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:31

Indicates whether the event is cancelable.

Implementation of

nx.NexoEvent.cancelable


data

readonly data: Data

Defined in: src/events/NexoEvent.ts:22

The data associated with the event.

Implementation of

nx.NexoEvent.data


name

readonly name: string

Defined in: src/events/NexoEvent.ts:19

The name of the event.

Implementation of

nx.NexoEvent.name


returnValue

returnValue: unknown

Defined in: src/events/NexoEvent.ts:34

The value to be returned by the event after it has been processed.

Implementation of

nx.NexoEvent.returnValue


target

readonly target: Target

Defined in: src/events/NexoEvent.ts:25

The target to which the event is dispatched.

Implementation of

nx.NexoEvent.target


timestamp

readonly timestamp: number

Defined in: src/events/NexoEvent.ts:28

The timestamp indicating when the event was created.

Implementation of

nx.NexoEvent.timestamp

Accessors

defaultPrevented

Get Signature

get defaultPrevented(): boolean

Defined in: src/events/NexoEvent.ts:93

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.

Implementation of

nx.NexoEvent.defaultPrevented

Methods

preventDefault()

preventDefault(): void

Defined in: src/events/NexoEvent.ts:75

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

Implementation of

nx.NexoEvent.preventDefault