API Reference
Rockets Core API
nestjs-event
classes
EventAsync

Class: abstract EventAsync<P, R>

Abstract async event class.

To create a custom async event, extend the EventAsync class.

You can override and customize the [payload]Event#payload getter if desired. Please read the documentation for the abstract Event class for the complete documentation.

For synchronous events, see the EventSync abstract class.

Example

// event payload type
type MyPayloadType = {id: number, active: boolean};
 
// event class
class MyEvent extends EventAsync<MyPayloadType> {}
 
// create an event
const myEvent = new MyEvent({id: 1234, active: true});

Extends

Extended by

Type Parameters

Type ParameterDefault type
Pundefined
RP

Implements

Constructors

new EventAsync()

new EventAsync<P, R>(payload?): EventAsync<P, R>

Constructor

Parameters

ParameterTypeDescription
payload?PPayload to emit when the event is dispatched.

Returns

EventAsync<P, R>

Inherited from

Event.constructor

Defined in

.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:69 (opens in a new tab)

Properties

PropertyModifierTypeDescriptionInherited from
expectsReturnOfreadonlyPromise<R>Internal Expects return of payloadEventAsyncInterface.expectsReturnOf Event.expectsReturnOf

Accessors

key

get key(): string

Event key.

Returns

string

The event key string.

Implementation of

EventAsyncInterface.key

Inherited from

Event.key

Defined in

.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:55 (opens in a new tab)


payload

get payload(): P

Returns payload that was passed to the Event constructor.

Returns

P

The event payload.

Implementation of

EventAsyncInterface.payload

Inherited from

Event.payload

Defined in

.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:85 (opens in a new tab)


key

get static key(): string

Event key.

Returns

string

The event key string.

Inherited from

Event.key

Defined in

.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:46 (opens in a new tab)