IceyIsAlreadyTaken / event-bus

A js event bus for simple sence.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event bus

Build Status codecov code style: prettier

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
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Opera
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.

About

A js event bus for simple sence.


Languages

Language:TypeScript 100.0%