@cherrypulp/pubsub

PubSub helpers

Usage no npm install needed!

<script type="module">
  import cherrypulpPubsub from 'https://cdn.skypack.dev/@cherrypulp/pubsub';
</script>

README

PubSub

codebeat badge Issues License npm version

PubSub helper.

Installation

npm install @cherrypulp/pubsub

Quick start

import * as event from '@cherrypulp/pubsub';

// or

import {emit, off, on, once} from '@cherrypulp/pubsub';

Methods

emit

Publish to the given channel.

emit('channel', args);

off

Remove the given subscriber.

off('channel');

on

Subscribe to a new or existing channel.

on('channel', () => console.log('foo'));

once

Subscribe to a new or existing channel and remove the subscriber when published.

once('channel', () => console.log('bar'));

Versioning

Versioned using SemVer.

Contribution

Please raise an issue if you find any. Pull requests are welcome!

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.