0.2.5 • Published 10 years ago

zemitter v0.2.5

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

zemitter

Flexible Event Emitter for Node and the Browser

Install

$ npm install zemitter

Usage

var Emitter = require('zemitter')
var obj = {}

//either make an object become an event emitter
Emitter(obj) // returns obj

//or create a brand new emitter
var emitter = Emitter()

Example

emitter.on({
    start: function(greeting, name){
        console.log(greeting, name)
    },
    stop: function(){

    },
    scope: {}
})
emitter.on('start', function(){

})
emitter.on({
    start: {
        fn: function(){

        },
        scope: ''
    },
    stop: function(){}
})

emitter.emit('start', 'hello', 'world')

API

on

emitter.on({
    'event_name': fn
})
emitter.on(['start','stop','exit'], fn)
emitter.on(['start','stop','exit'], [fn1, fn2])

off

emitter.off('start', fn)// remove fn as a listener to the 'start' event emitter.off('start') // remove all listeners to the start event emitter.off() // remove all listeners attached to this emitter

once

Attach a function that will only be called once, and then will be removed from the emitter

Tests

$ make

License

MIT
0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago