2.0.0 • Published 8 months ago

@marianmeres/pubsub v2.0.0

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

@marianmeres/pubsub

Basic publish-subscribe.

Install

deno add jsr:@marianmeres/pubsub
npm install @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');
2.0.0

8 months ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.0

2 years ago

1.0.0

3 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