entangle.ts
Version:
A declarative, event-driven framework for orchestrating business logic in TypeScript & Node.js applications.
21 lines (20 loc) • 1.11 kB
TypeScript
import { Aether } from '../Aether';
import { Callback } from '../../shared/types/Utils.types';
import { Boson, Entanglement } from '../../shared/types/Particles.types';
import { Event } from '../../shared/types/Events.types';
/**
* An in-memory implementation of the Aether using Node.js's native EventEmitter.
*
* This implementation is perfect for development, testing, and simple single-process applications.
*
* **Warning:** It is not recommended for horizontally-scaled production environments
* (e.g., using Node.js 'cluster' module, PM2 cluster mode, or multiple servers).
* Events are bound to a single process's memory and cannot be shared across different
* processes or machines. Be aware that using it on a production environment cal also lead to an increase in memory consumption.
*/
export declare class InMemoryAether extends Aether {
private readonly _emitter;
on(event: Event, callback: Callback<[Boson]>): void;
once(event: Event, callback: Callback<[Boson]>): void;
emit<TArgs extends unknown[]>(event: Event, entanglement: Entanglement, ...args: TArgs): void;
}