1.1.8 • Published 5 years ago

subnpub v1.1.8

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

subnpub

CircleCI

Minimal implementation of publish/subscribe pattern

USAGE

const SubNPub = require("subnpub");
const snp = SubNPub();

const fn1 = str => `1-Called Me with: ${str}`;
const fn2 = str => `2-Called Me with: ${str}`;
const fn3 = str => `3-Called Me with: ${str}`;

// subscribe enforces uniqueness
snp.subscribe(fn1);
// or:
snp.subscribe(fn1, fn2, fn3);
// or:
snp.subscribe([fn1, fn2, fn3]);


snp.publish("test"); // dispatches argument to all subscribers

snp.has(fn1); // true

snp.length(); // 3


snp.unsubscribe(fn1); // removes subscriber
// or:
snp.unsubscribe(fn1, fn2, fn3);
// or:
snp.unsubscribe([fn1, fn2, fn3]);

snp.reset(); // removes all subscribers
1.1.8

5 years ago

1.1.7

6 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago