Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Latest commit

 

History

History
30 lines (17 loc) · 1.13 KB

README.md

File metadata and controls

30 lines (17 loc) · 1.13 KB

Cachable Pub/Sub Codeship Status for sevilyilmaz/pubsub Code Climate Test Coverage

Pub/Sub library that keeps historical data. It's possible to publish before subscription then subscribe and get the data that was published.

Usage

Subscription

pubsub.sub([ID], callback);
pubsub.sub('lorem', (data) => data);

Publish

pubsub.pub([ID], data);
pubsub.pub('lorem', 'ipsum');
pubsub.pub('lorem', { data: 'ipsum'});

You may pass multiple arguments to the subscription.

pubsub.pub('lorem', 'ipsum', 'dolor');

Unsubscribe

To unsubscribe from all subscriptions that has the ID "lorem".

pubsub.unsub('lorem');

To unsubscribe from only one subscription that has the ID "lorem".

pubsub.unsub('lorem', callback);