1.1.8 • Published 6 years ago

subnpub v1.1.8

Weekly downloads
1
License
ISC
Repository
github
Last release
6 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

6 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago