Defines base classes and interfaces for a decoupled event-driven architecture. Use this to implement custom event publishing and handling logic across modular applications.
// Source: https://github.com/webiny/webiny-js | License: MIT | Copyright Webiny Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type { Abstraction } from "@webiny/di";
import { createAbstraction } from "@webiny/feature/admin";
export abstract class BaseEvent<TPayload = void> {
public abstract readonly eventType: string;
public readonly occurredAt: Date;
public readonly payload: TPayload extends void ? undefined : TPayload;
constructor(payload: TPayload);
constructor(payload?: never) {
this.occurredAt = new Date();
if (payload === undefined) {
this.payload = undefined as any;
} else {
this.payload = payload;
}
}
abstract getHandlerAbstraction(): Abstraction<IEventHandler<any>
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key