Skip to content

EventHandler

Christian Prinz edited this page Oct 17, 2022 · 1 revision

Class: EventHandler<Payload>

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

Type parameters

Name
Payload

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new EventHandler<Payload>(name)

Type parameters

Name
Payload

Parameters

Name Type
name string

Defined in

event/EventHandler.ts:17

Properties

_name

Protected _name: string

Defined in

event/EventHandler.ts:13


_occurred

Protected _occurred: boolean = false

Defined in

event/EventHandler.ts:15


_subscriptions

Protected _subscriptions: Map<string, Subscription<Payload>>

Defined in

event/EventHandler.ts:14

Accessors

name

get name(): string

Returns

string

Defined in

event/EventHandler.ts:21


occurred

get occurred(): boolean

indicates if a DomainEvent has at least once been fired

Returns

boolean

Defined in

event/EventHandler.ts:26

Methods

dispatch

dispatch(payload): void

Dispatches that the handled event has been fired. Therefore, all Subscribers callbacks are called with the given optional payload.

Parameters

Name Type Description
payload Payload (optional) payload to broadcast to all Subscribers

Returns

void

Defined in

event/EventHandler.ts:58


logDispatch

Protected logDispatch(): void

Returns

void

Defined in

event/EventHandler.ts:78


logDispatchedSubscription

Protected logDispatchedSubscription(subscription): void

Parameters

Name Type
subscription Subscription<Payload>

Returns

void

Defined in

event/EventHandler.ts:82


logSubscribe

Protected logSubscribe(name): void

Parameters

Name Type
name string

Returns

void

Defined in

event/EventHandler.ts:70


logUnsubscribe

Protected logUnsubscribe(name): void

Parameters

Name Type
name string

Returns

void

Defined in

event/EventHandler.ts:74


subscribe

subscribe(name, callback, suppressLogging?): void

Parameters

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

Returns

void

Defined in

event/EventHandler.ts:35


unsubscribe

unsubscribe(name): void

Parameters

Name Type Description
name string of the Subscriber that has to match the name, the subscription was made with

Returns

void

Defined in

event/EventHandler.ts:47

DDD basics - v0.0.1

Clone this wiki locally