Class: abstract
Event<P, R>
Abstract event class.
To create a custom event, extend the Event class.
You must implement one of the EventSyncInterface or EventAsyncInterface interfaces.
There are additional abstract classes available which have implemented the sync and async event types for your convenience. They are EventSync and EventAsync.
Example
// event payload type
type MyPayloadType = {id: number, active: boolean};
// event class
class MyEvent extends Event<MyPayloadType>
implements EventSyncInterface<MyPayloadType>
{}
// create an event
const myEvent = new MyEvent({id: 1234, active: true});
Extended by
Type Parameters
Type Parameter | Default type |
---|---|
P | undefined |
R | P |
Implements
EventInterface
<P
,R
>
Constructors
new Event()
new Event<
P
,R
>(payload
?):Event
<P
,R
>
Constructor
Parameters
Parameter | Type | Description |
---|---|---|
payload ? | P | Payload to emit when the event is dispatched. |
Returns
Event
<P
, R
>
Defined in
.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:69 (opens in a new tab)
Properties
Property | Modifier | Type | Description |
---|---|---|---|
expectsReturnOf | readonly | R | Internal Expects return of payload |
Accessors
key
get
key():string
Event key.
Returns
string
The event key string.
Implementation of
EventInterface
.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
EventInterface
.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.
Defined in
.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:46 (opens in a new tab)