1.2.5 • Published 10 months ago

@marianmeres/pubsub v1.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@marianmeres/pubsub

Basic publish-subscribe.

Install

$ npm i @marianmeres/pubsub

Usage

import { createPubSub } from '@marianmeres/pubsub;
const { publish, subscribe, subscribeOnce, unsubscribe, unsubscribeAll } = createPubSub();

// create subscription (returns unsub function)
const unsub = subscribe('foo', console.log);

// publish
publish('foo', 'bar'); // logs 'bar'

// unsubscribe
unsub();
// or more general alternatives to above
unsubscribe('foo', console.log);
unsubscribeAll('foo');

// now this is a no-op as no subscription exists
publish('foo', 'baz');
1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.0

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.1.0

2 years ago

1.0.0

2 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago