entangle.ts
Version:
A declarative, event-driven framework for orchestrating business logic in TypeScript & Node.js applications.
31 lines (30 loc) • 1.59 kB
TypeScript
import { Event } from '../shared/types/Events.types';
import { Boson, Entanglement } from '../shared/types/Particles.types';
import { Callback } from '../shared/types/Utils.types';
/**
* For centuries, scientists believed light required a medium to propagate through space,
* much like sound requires the air. This theoretical, all-pervading substance was named the `Aether`.
*
* In our framework, the **`Aether`** is this medium. It is the core component
* responsible for emitting and listening to events, allowing them to propagate throughout the application.
*/
export declare abstract class Aether {
/**
* Subscribes to an event, executing a callback function each time it is emitted.
* @param event The name of the event to listen for.
* @param callback The function to be executed when the event occurs.
*/
abstract on(event: Event, callback: Callback<[Boson]>): void;
/**
* Subscribes to an event for a single execution. The listener is automatically removed after the event occurs once.
* @param event The name of the event to listen for.
* @param callback The function to be executed when the event occurs for the first time.
*/
abstract once(event: Event, callback: Callback<[Boson]>): void;
/**
* Emits an event, propagating it through the Aether to all subscribed listeners.
* @param event The name of the event to emit.
* @param args The data or arguments to pass to the listeners' callback functions.
*/
abstract emit(event: Event, entanglement: Entanglement, ...args: unknown[]): void;
}