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
Event
<P
,Promise
<R
>>
Extended by
Type Parameters
Type Parameter | Default type |
---|---|
P | undefined |
R | P |
Implements
EventAsyncInterface
<P
,R
>
Constructors
new EventAsync()
new EventAsync<
P
,R
>(payload
?):EventAsync
<P
,R
>
Constructor
Parameters
Parameter | Type | Description |
---|---|---|
payload ? | P | Payload to emit when the event is dispatched. |
Returns
EventAsync
<P
, R
>
Inherited from
Defined in
.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:69 (opens in a new tab)
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
expectsReturnOf | readonly | Promise <R > | Internal Expects return of payload | EventAsyncInterface .expectsReturnOf Event .expectsReturnOf |
Accessors
key
get
key():string
Event key.
Returns
string
The event key string.
Implementation of
Inherited from
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
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
Defined in
.tmp/repos/rockets/packages/nestjs-event/src/events/event.ts:46 (opens in a new tab)