UNPKG

@nivinjoseph/n-eda

Version:

Event Driven Architecture framework

24 lines (19 loc) 519 B
import { given } from "@nivinjoseph/n-defensive"; export interface EdaContext { get topic(): string; } export class DefaultEdaContext implements EdaContext { private _topic: string | null = null; public get topic(): string { given(this, "this").ensure(t => t._topic != null, "topic not set"); return this._topic!; } public set topic(value: string) { given(value, "topic").ensureHasValue().ensureIsString(); this._topic = value.trim(); } }