-
Notifications
You must be signed in to change notification settings - Fork 0
EventHandler
A Handler that allows Subscribers (any caller) to subscribe to a specific event. All Subscribers will be notified if the event dispatcher dispatched the event
| Name |
|---|
Payload |
• new EventHandler<Payload>(name)
| Name |
|---|
Payload |
| Name | Type |
|---|---|
name |
string |
• Protected _name: string
• Protected _occurred: boolean = false
• Protected _subscriptions: Map<string, Subscription<Payload>>
• get name(): string
string
• get occurred(): boolean
indicates if a DomainEvent has at least once been fired
boolean
▸ dispatch(payload): void
Dispatches that the handled event has been fired. Therefore, all Subscribers callbacks are called with the given optional payload.
| Name | Type | Description |
|---|---|---|
payload |
Payload |
(optional) payload to broadcast to all Subscribers |
void
▸ Protected logDispatch(): void
void
▸ Protected logDispatchedSubscription(subscription): void
| Name | Type |
|---|---|
subscription |
Subscription<Payload> |
void
▸ Protected logSubscribe(name): void
| Name | Type |
|---|---|
name |
string |
void
▸ Protected logUnsubscribe(name): void
| Name | Type |
|---|---|
name |
string |
void
▸ subscribe(name, callback, suppressLogging?): void
| Name | Type | Default value | Description |
|---|---|---|---|
name |
string |
undefined |
of the calling Subscriber |
callback |
(event: DomainEvent<Payload>) => void
|
undefined |
to call if the event has been dispatched |
suppressLogging |
boolean |
false |
suppresses the usage of the extendable logging functionality of this handler |
void
▸ unsubscribe(name): void
| Name | Type | Description |
|---|---|---|
name |
string |
of the Subscriber that has to match the name, the subscription was made with |
void