Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pajaydev/build-own-pubsub

A simplified implementation to learn how to build our own pubsub (publisher-subscriber pattern)
https://github.com/pajaydev/build-own-pubsub

build-pubsub build-your-own-pubsub event-emitter learn-pubsub listener publisher publisher-subscriber publisher-subscriber-pattern pubsub topic write-your-own-pubsub

Last synced: about 4 hours ago
JSON representation

A simplified implementation to learn how to build our own pubsub (publisher-subscriber pattern)

Awesome Lists containing this project

README

        

## build-pubsub

> A simplified implementation to learn how to build our own pubsub (publisher-subscriber pattern).

### How do I learn?
source code: [build-pubsub]

### Want to try

```sh
$ npm install build-pubsub
```

### how to use
```js
const Pubsub = require('build-pubsub');
const pubsub = new Pubsub();
pubsub.on('AJAX', ajaxFunc);
pubsub.on('AJAX', ajaxAnotherFunc);
pubsub.emit('AJAX', args); // fires both ajaxFunc & ajaxAnotherFunc with args
```
### Some of the useful links to learn pubsub.

- [Publisher subscriber pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)
- [Observer vs pubsub pattern](https://hackernoon.com/observer-vs-pub-sub-pattern-50d3b27f838c)
- [Enterprise integeration patterns](https://www.enterpriseintegrationpatterns.com/patterns/messaging/PublishSubscribeChannel.html)
- [What is pubsub](https://blog.stackpath.com/pub-sub/)