@actdim/msgmesh
v1.5.15
Published
A type-safe, modular message mesh for scalable async communication in TypeScript
Maintainers
Readme
@actdim/msgmesh
Type-Safe Async Message Mesh & Service Bus for Scalable TypeScript Applications
What is MsgMesh?
@actdim/msgmesh is a high-performance, type-safe messaging framework and service mesh for TypeScript. It bridges the gap between raw EventEmitter callbacks, complex RxJS streams, and tightly-coupled state managers by providing a unified message bus for Pub/Sub Events, RPC Request/Response, Fan-in Streams, and Automated Service Adapters.
The Problem It Solves
- Untyped Events: Fatigued by string typos, missing payload types, and runtime crashes when emitting events?
- RxJS Complexity Overload: Want the power of reactive streams and debouncing without forcing your entire team into complex RxJS operators?
- Tightly-Coupled Services: Want UI components to invoke backend APIs or cross-module services without hard-coded class imports or prop callback chains?
The Output You Get
- 🔒 100% Compile-Time Verification: Channels, input/output groups, and headers are checked by TypeScript with full IDE autocomplete.
- ⚡ RPC & Cancellation: Built-in
request()/provide()withAbortSignalcancellation support out-of-the-box. - 🔌 Service Adapters: Automatically wrap NSwag / OpenAPI / gRPC API clients directly into typed message channels.
- 🚀 Built on RxJS: Enterprise-grade scheduler under the hood, clean imperative API on top.
15-Second Code Snippet
import { MsgStruct, createMsgBus } from '@actdim/msgmesh';
// 1. Declare contract (Channels, Inputs, Outputs)
type AppBusStruct = MsgStruct<{
'USER.GET_PROFILE': { in: { userId: string }; out: { name: string; email: string } };
}>;
// 2. Instantiate bus
const msgBus = createMsgBus<AppBusStruct>();
// 3. Register RPC provider
msgBus.provide({
channel: 'USER.GET_PROFILE',
callback: async (msg) => ({ name: 'Alice', email: '[email protected]' }),
});
// 4. Request data from anywhere in the app with 100% type safety
const profile = await msgBus.request({
channel: 'USER.GET_PROFILE',
payload: { userId: 'usr-123' },
});
console.log(profile.payload.name); // "Alice"Installation
pnpm add @actdim/msgmesh @actdim/utico rxjsDocumentation Index
Explore the complete guide step-by-step from core concepts to advanced service adapters:
| Section | Description |
|---|---|
| 📖 01. Overview & Problem Analysis | Motivation, comparison with EventEmitters, RxJS, and global state managers. |
| 🧩 02. Architecture & Types | Channels, Input/Output groups, type contracts, and bus instantiation. |
| 🛠️ 03. API Reference | Complete method reference (send, on, once, stream, provide, request, requestStream). |
| 🚀 04. Advanced Patterns & Adapters | Message replay, debouncing, chain-of-responsibility, and automated service adapters. |
Interactive Browser Sandbox
Try @actdim/msgmesh instantly in StackBlitz:
AI-Assisted Development
Developed with Along - a provider-agnostic context and memory system for AI coding agents.
License
MIT License. See LICENSE for details.
