GitXplorerGitXplorer
j

boomerang

public
3 stars
0 forks
2 issues

Commits

List of commits on branch master.
Unverified
b3079d4590ceaba7de15ca0119966e780217f734

0.2.0

committed 11 years ago
Unverified
8ee6c64bda1168f6346e92edb25271b2d41b26ae

Update README.

committed 11 years ago
Unverified
c7c9bc7d55ab76e8952c4bb426fc3947a37edc9b

Add sync bindings along with the ability to cancel callback execution.

committed 11 years ago
Unverified
6576e8168fe9d2f2d7e314b0d73d861ffed0efe5

Update README.

jjharding committed 11 years ago
Unverified
c3049baf613772ae3b5ad1fd7bb6d0bfb95a526f

0.1.0

committed 11 years ago
Unverified
3b5efdf47f8d89e83501db9a22a3d6f56cd24adb

Add README.

committed 11 years ago

README

The README file for this repository.

build status

Boomerang

An event emitter that supports calling handlers both synchronously and asynchronously. It can be used to mix in event emitter functionality into an arbitrary object, or it can be used as a global event bus.

Download

Usage

API

boomerang.mixin(obj)

Adds the onSync, onAsync, off, and trigger methods to obj.

boomerang#onSync(event, callback, context)

Binds callback to the object. callback will be invoked synchronously when event is triggered. If context is set, that is the context callback will be invoked in.

boomerang#onAsync(event, callback, context)

Binds callback to the object. callback will be invoked asynchronously when event is triggered. If context is set, that is the context callback will be invoked in.

boomerang#off(event)

Removes previously-bound callbacks.

boomerang#trigger(event, [,args])

Triggers previously registered callbacks for event. Additional arguments will be passed to the callbacks when invoked. Callbacks will be invoked in the order they were attached. If a callback explicitly returns false, that will stop callback execution.

Example

var asyncEventEmitter = boomerang.mixin({}), testVal;

asyncEventEmitter.onAsync('event', callback).trigger('event', 42);

assert(testVal === undefined);
setTimeout(function() { assert(testVal === 42); }, 100);

function callback(event, val) {
  assert(event === 'event'); 
  testVal = val;
}

Testing

Tests are written using Jasmine and ran with Karma. To run Boomerang's test suite with PhantomJS, run npm test.

Issues

Found a bug? Create an issue on GitHub.

https://github.com/jharding/boomerang/issues

Versioning

For transparency and insight into the release cycle, releases will be numbered with the follow format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backwards compatibility bumps the major
  • New additions without breaking backwards compatibility bumps the minor
  • Bug fixes and misc changes bump the patch

For more information on semantic versioning, please visit http://semver.org/.

License

Copyright (c) 2013 Jake Harding
Licensed under the MIT License.