Skip to content
/ PubSub Public

⭐ Javascript implementation of the Publish/Subscribe design pattern.

License

Notifications You must be signed in to change notification settings

moaali/PubSub

Repository files navigation

PubSub

Dependency free Javascript implementation of the Publish/Subscribe design pattern.

Example Usages

const fn1 = data => { console.log(`${data} from fn1`) }
const fn2 = data => { console.log(`${data} from fn2`) }
const fn3 = data => { console.log(`${data} from fn3`) }

PubSub.subscribe('FUNCTIONS', fn1);
PubSub.subscribe('FUNCTIONS', fn2);
PubSub.subscribe('FUNCTIONS', fn3);

PubSub.publish('FUNCTIONS', 'Hello');
// => Hello from fn1
// => Hello from fn2
// => Hello from fn3

PubSub.unsubscribe('FUNCTIONS', 'fn3');

PubSub.publish('FUNCTIONS', 'Hello');
// => Hello from fn1
// => Hello from fn2

About

⭐ Javascript implementation of the Publish/Subscribe design pattern.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published