2.0.6 • Published 6 years ago

fn-emitter v2.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

fn-emitter

Extend your function with an event emitter.

Installation  

$ npm install fn-emitter

Usage

var Emitter = require("fn-emitter");

var Demo = function(){ new Emitter(this); }

var demo = new Demo(); var cb = function(msg){ console.log(msg); };

register an event listener

demo.on("test",cb);

emit an event

demo.emit("test","successfully emitted and recieved");

remove the event listener

demo.off("test",cb)

api

on : register an event listener .on("event name",callback)

emit : emit an event. .emit("event name",params...)

off : unregister an event listener or all listeners for an event .off("event name",cb) .off("event name") - if 2nd parameter is not specified then all listeners for the specific event is unregistered.

demo at https://runkit.com/586a7335e32a6d00155783d4/586bf0754fcd4e0014699586

License

MIT © 2016 contributors

2.0.6

6 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago