larzevents
A pub/sub event emitter.
When one thing happens, several others often need to react. Wiring them directly tangles everything. An event emitter decouples them: the code just announces 'user.created' and whoever cares listens. larzevents is a small, readable pub/sub emitter - on, once, off, emit.
larzscript pkg install events
What you get
- on / once / off / emit
- Decouple components cleanly
- emit returns handlers-run count
- Safe to modify during emit
Try it
import "events" as events
let e = events.new()
let id = events.on(e, "save", fn(data) { print("saved", data) })
events.once(e, "save", fn(data) { print("first save only") })
print("ran:", events.emit(e, "save", "payload"))
print("ran again:", events.emit(e, "save", "payload2"))Output
saved payload first save only ran: 2 saved payload2 ran again: 1
Why it's in the Larz Stack
larzevents is a real Larzscript package (larzscript pkg install events) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.