biojs-events
Advanced tools
Comparing version 0.0.2 to 0.0.3
17
index.js
var events = require("backbone-events-standalone"); | ||
events.onAll = function(callback,context){ | ||
this.on("all", callback,context); | ||
return this; | ||
}; | ||
// Mixin utility | ||
events.mixin = function(proto) { | ||
var exports = ['on', 'once', 'off', 'trigger', 'onAll', 'stopListening', 'listenTo', | ||
'listenToOnce', 'bind', 'unbind']; | ||
for(var i=0; i < exports.length;i++){ | ||
var name = exports[i]; | ||
proto[name] = this[name]; | ||
} | ||
return proto; | ||
}; | ||
module.exports = events; |
{ | ||
"name": "biojs-events", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "BioJS event system", | ||
@@ -25,3 +25,14 @@ "main": "index.js", | ||
"backbone-events-standalone": "^0.2.2" | ||
} | ||
}, | ||
"devDependencies": { | ||
"mocha": "1.8.x", | ||
"chai": "1.5.x", | ||
"jshint": "2.x", | ||
"underscore": "1.4.x", | ||
"grunt": "0.4.x", | ||
"grunt-contrib-uglify": "0.2.x" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
} | ||
} |
new event system | ||
event system | ||
------------------ | ||
This is a convenience wrapper for the [Event system](https://github.com/biojs/biojs2/wiki/Event-systems). | ||
You can choose any library that supports the choosen syntax. | ||
This wrapper here is for [`backbone-events-standalone`](https://www.npmjs.org/package/backbone-events-standalone) and thus the Backbone event system. | ||
How to use | ||
---------- | ||
### 1. install | ||
``` | ||
npm install biojs-events --save | ||
``` | ||
### 2. Mix the events capability with your object | ||
After the code of your BioJS component add the events capability by mixing you component object with the events: | ||
``` | ||
require('biojs-events').mixin(my_component); | ||
``` | ||
### 3. Trigger events | ||
Now in your code you can use the events methods (trigger, off,on,once): | ||
``` | ||
self.trigger('onSomethingChanged', { | ||
data : "some data to include in your event" | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
16633
5
442
38
6