ts-super-emitter
v1.0.2A tiny event emitter with events typed end to end - subscribe(), emit(), and once() all infer their argument types from a single Events map, so the wrong event name or payload shape is a compile error, not a runtime bug.
- +Fully typed events - the payload shape is enforced at compile time
- +once() for single-fire listeners, subscribe() returns an unsubscribe fn
- +clear() for full teardown - no leaked listeners
- +Zero dependencies, tiny footprint
// usage
index.ts
import { Emitter } from "ts-super-emitter"; type Events = { message: [text: string];}; const emitter = new Emitter<Events>(); emitter.subscribe("message", (text) => { console.log(text);}); emitter.emit("message", "Hello world");// result
two components, one shared emitter
Sender.tsx
emitter.emit("message", text)
// 0 emitted this session
Receiver.tsx
emitter.subscribe("message", cb)
// waiting for events...