Skip to content

Notify Background

Notify Background

@lou.codes/notify is a tiny functional curried library to setup a simple pub/sub system. It only has 3 functions: emit, on and broadcast. This last is just bundling the other two and linking them to the same state.

Why

This one started as a work requirement. Looking for a pub/sub library I found a bunch, but they were either an โ€œoverkillโ€, filled with unwanted features, or too old, or to โ€œclass basedโ€. So I decided to make my own.

How

I built this library using TypeScript, with configurations from my shared configs. I made it ESM only because CJS no longer made sense when I created this (Node started supporting ESM modules a long time ago), and I made it tree-shakeable by using named exports.

It took around 2 hours to be done, thanks to it relying on a lot of my other packages. I created with with create-package, and I used , iterables, predicates, utils, test and types.

It took longer to think how I wanted the API to look like, than actually making it a reality. I started with on and emit, broadcast came later when I figure out how I wanted to make it as functional as possible.

Where

Iโ€™ve used this at work in private projects only, so no public usages yet, but as any other of my libraries, you can play with it in your browser terminal by going to the reference.