项目
在 GitHub 查看
postaljs/postal.js
关于
一个 JavaScript 发布/订阅库,支持高级订阅功能,并提供多个实用扩展。
开发工具可以做什么
- TypeScript-first — full type inference on channels, topics, and message data
- AMQP-style wildcards — * matches a single topic segment, # matches zero or more
- Channel-scoped messaging — isolate message domains with named channels
- Request/handle RPC — built-in request/response pattern
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 0
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文postal
Pub/Sub message bus for JavaScript and TypeScript.
Features
- TypeScript-first — full type inference on channels, topics, and message data
- AMQP-style wildcards —
*matches a single topic segment,#matches zero or more - Channel-scoped messaging — isolate message domains with named channels
- Request/handle RPC — built-in request/response pattern
- Wire taps — global observers that see every message on the bus
- Transport system — bridge pub/sub across iframes, workers, and browser tabs
- Zero dependencies — no lodash, no nothing
Install
npm install postal
Quick Example
import { getChannel } from "postal";
const orders = getChannel("orders");
orders.subscribe("order.created", envelope => {
console.log("New order:", envelope.payload.orderId);
});
orders.publish("order.created", { orderId: "abc-123" });
For the full API — wildcards, RPC, wire taps, transports — see the docs.
Upgrading from v2? postal v3 is a ground-up rewrite with breaking changes to the module system, subscriber callbacks, envelope shape, and more. See the v2 → v3 migration guide before upgrading.
Packages
| Package | npm | Description |
|---|---|---|
| postal | postal |
Core message bus |
| postal-transport-messageport | postal-transport-messageport |
MessagePort transport for iframes and workers |
| postal-transport-broadcastchannel | postal-transport-broadcastchannel |
BroadcastChannel transport for cross-tab messaging |
| postal-transport-serviceworker | postal-transport-serviceworker |
ServiceWorker transport — dedicated MessagePort per tab, presence tracking, SW restart resilience |
| postal-transport-childprocess | postal-transport-childprocess |
child_process/cluster IPC transport for Node.js |
| postal-transport-uds | postal-transport-uds |
Unix domain socket transport for independent Node.js processes |
Development
pnpm install # Install dependencies
pnpm build # Build all packages
pnpm test # Run all tests
pnpm lint # Lint all packages
pnpm run checks # lint + test + build (CI gate)
License
MIT
探索相关项目
加载中…