Skip to content

Super lightweight Subscribe/Publish event system for Node.js and browser

License

Notifications You must be signed in to change notification settings

Cap32/subscribable-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

subscribable-lite

Build Status Coverage Status

Super Light weight Subscribe/Publish event system for Node.js and browser. (UMD version only 395B after gzipped)

Installing

Using npm:

$ npm install subscribable-lite

Using yarn:

$ yarn add subscribable-lite

Usage

sub.subscribe(handler)

sub.publish([arg[, ...]])

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])

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)

About

Super lightweight Subscribe/Publish event system for Node.js and browser

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published