https://github.com/cap32/subscribable-lite
Super lightweight Subscribe/Publish event system for Node.js and browser
https://github.com/cap32/subscribable-lite
events publish-subscribe subscribe tiny
Last synced: 7 months ago
JSON representation
Super lightweight Subscribe/Publish event system for Node.js and browser
- Host: GitHub
- URL: https://github.com/cap32/subscribable-lite
- Owner: Cap32
- License: mit
- Created: 2016-10-25T04:50:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-08T09:11:06.000Z (about 8 years ago)
- Last Synced: 2025-01-27T13:48:28.357Z (9 months ago)
- Topics: events, publish-subscribe, subscribe, tiny
- Language: JavaScript
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# subscribable-lite
[](https://travis-ci.org/Cap32/subscribable-lite) [](https://coveralls.io/github/Cap32/subscribable-lite?branch=master)
Super Light weight Subscribe/Publish event system for Node.js and browser. (UMD version only 395B after gzipped)
## Installing
Using npm:
```bash
$ npm install subscribable-lite
```Using yarn:
```bash
$ yarn add subscribable-lite
```## Usage
sub.subscribe(handler)
sub.publish([arg[, ...]])
```js
import SubLite from 'subscribable-lite';const sub = new SubLite();
sub.subscribe((a, b, c) => {
console.log(a, b, c); // => 'you are awesome'
});
sub.publish('you', 'are', 'awesome');
```sub.unsubscribe([handler])
```js
const unsubscribe = sub.subscribe((a, b, c) => {
console.log(a, b, c); // => 'will not trigger'
});unsubscribe();
/* or `sub.unsubscribe();` */sub.publish('you', 'are', 'awesome');
```## License
MIT (c) Christopher Peng (Cap32)