From 1840d4370ecd5b8e61f9302b7855b3ce880cfe41 Mon Sep 17 00:00:00 2001 From: Julien Blin Date: Mon, 27 Aug 2018 18:47:25 -0400 Subject: [PATCH] Added ForwardEventDispatcher (#66) Fix #63 --- CHANGELOG.md | 1 + .../uno-serverless/src/events/event-dispatcher.ts | 13 +++++++++++++ .../uno-serverless/src/events/event-publisher.ts | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 154367d..575b6e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - CLI: generate-schemas: added -config option to specify tsconfig.json file (Fix #60) - HttpClient: Added debug mode (Fix #62) - Added clear() and list() to KeyValueRepository (Fix #57) +- Added ForwardEventDispatcher (Fix #63) ## [0.49.0] - 2018-08-23 ### Added diff --git a/packages/uno-serverless/src/events/event-dispatcher.ts b/packages/uno-serverless/src/events/event-dispatcher.ts index 1866b29..a6afe14 100644 --- a/packages/uno-serverless/src/events/event-dispatcher.ts +++ b/packages/uno-serverless/src/events/event-dispatcher.ts @@ -61,3 +61,16 @@ export class LocalEventDispatcher implements EventPublisher, EventDispatcher { } } + +/** + * Very simple EventDispatcher that forwards events to a different EventPublisher. + */ +export class ForwardEventDispatcher implements EventDispatcher { + + public constructor(private readonly publisher: EventPublisher) {} + + public dispatch(evt: Event): Promise { + return this.publisher.publish(evt); + } + +} diff --git a/packages/uno-serverless/src/events/event-publisher.ts b/packages/uno-serverless/src/events/event-publisher.ts index 3813198..af562ee 100644 --- a/packages/uno-serverless/src/events/event-publisher.ts +++ b/packages/uno-serverless/src/events/event-publisher.ts @@ -1,6 +1,6 @@ import { Event } from "./event"; -/** EventPublisher publishes event for defered execution. */ +/** EventPublisher publishes event for deferred execution. */ export interface EventPublisher { /**