Evee.js Save

The lightweight es6 event library.

Project README

GitHub license npm Travis Gratipay

evee.js

The blazing fast ES6 event library.

Evee is a lightweight event library, written in clean ECMAScript6.
Evee exports both an ES5 and an ES6 version to support a wide range of clients.

Status

The project is still actively maintained, but the functionality is complete.
Bugs will still be fixed and feature requests are more than welcome.

How to upgrade from evee 1.x to evee 2.1.0+

As of version 2.1.0, evee exports two entry points: evee and evee/es6.
The evee export is what you're used to, and will work with all ES5 compatible targets.
The evee/es6 export is the ES6 version of evee, which is generally faster.

If you wanna keep using the ES5 version, you don't need to change anything!
If you wanna upgrade to the beautiful ES6 version, here's how to do it:

// Importing evee/es6 (require)
const Evee = require('evee/es6'),
      evee = new Evee;

// Importing evee/es6 (ES6 modules)
import Evee from 'evee/es6';
const  evee = new Evee;

How to use

// Grab a new evee instance
const Evee = require('evee/es6'),
      evee = new Evee;

// Subscribe to the 'update' event
evee.on('update', e => console.log(`Ticks: ${e.data}`));

var ticks = 0;
while(true) {

  // Dispatch the 'update' event
  evee.emit('update', ++ticks);
}

You can also keep track of your event listeners unsubscribe from events you don't need anymore.

// Grab a new evee instance
const Evee = require('evee/es6'),
      evee = new Evee;

// Subscribe to the 'say' event
var receiver = evee.on('say', e => console.log(e.data));

// Dispatch the 'say' event
evee.emit('say', 'Hello, world!');

// Unsubscribe from the 'say' event
evee.drop(receiver);

If you want to fire an event only once, you can do that too!
The event will be automatically removed after the first usage:

// Grab a new evee instance
const Evee = require('evee/es6'),
      evee = new Evee;

// Subscribe to the 'say' event
evee.once('say', e => console.log('hello, world'));

// Dispatch the 'say' event two times
evee.signal('say');
evee.signal('say');

// hello, world is only printed once!

As you can see, evee is really easy to use!
Start using evee today and stop worrying about slow events :)

Running the benchmarks

$ git clone [email protected]:SplittyDev/evee.js.git
$ cd evee.js
$ npm install --only=dev
$ npm run-script bench-dev
Open Source Agenda is not affiliated with "Evee.js" Project. README Source: SplittyDev/evee.js
Stars
194
Open Issues
1
Last Commit
7 years ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating