fizz-event-bus
v1.1.1
Published
a js event bus for simple sence.
Downloads
1
Readme
Event bus
A minimalism but expressive event bus for JS pub/sub scene. Just for simple scene. You can add your own feature free.
Browsers support
| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Opera | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | IE8, IE9, IE10, IE11, Edge | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 2 versions |
Install
yarn add fizz-event-bus --save
Usage
import eventBus from "fizz-event-bus";
// ES3 兼容
// import eventBus from "fizz-event-bus/lib/es3/index";
function hander(param) {
console.log(param);
}
eventBus.on("foo", handler);
// somewhere after import from 'fizz-event-bus'
eventBus.emit("foo", "bar");
As default, eventBus is a global object. But you can import the eventBus constructor for create a new EventBus or inherit it.