1.0.7 • Published 10 years ago

eventthing v1.0.7

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

eventthing

Installation

> npm install eventthing

Browserify Usage

var et = require('eventthing');

et.on('foo', function(arg){
	console.log('recieved', arg);
});

et.emit('foo', 'hello world');

Old Fashioned Usage

We love browserify, not everyone does though. Here's how you would use eventthing using global scope.

var et = window.Eventthing;

et.on('foo', function(arg){
	console.log('recieved', arg);
});

et.emit('foo', 'hello world');

You can also register multiple events and subscribers:

// subscribe to multiple events
et.on(['foo', 'bar'], function(arg){
	// handle foo or bar
});

// subscribe multiple listeners to one event
et.on('foo', [console.log, console.log]); 

// publish multiple events
et.emit(['foo','bar']);

// use an object to subscribe to multiple events
et.on({
	foo:function(){...},
	bar:function(){...}
});

// subscribe to all events
et.on('*', function(){...});

License

MIT

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago