0.0.1 • Published 10 years ago
angular-event-aggregator v0.0.1
angular-event-aggregator
$digest-free Event Aggregator for AngularJS inspired by Backbone's event aggregator.
Usage
Include angular-event-aggregator.js after your main AngularJS script.
Specify ngEventAggregator as a dependency for your Angular application:
var app = angular.module('myApp', ['ngEventAggregator']);Now you can inject eventAggregator anywhere in your application, and register a listener.
app.controller("MyCtrl", ['eventAggregator', function(eventAggregator){
var myCallback = function(item) {
console.log(item);
eventAggregator.off('some.event.happens', myCallBack);
};
eventAggregator.on('some.event.happens', myCallBack);
}]);or execute a trigger.
app.controller("SomeOtherCtrl", ['eventAggregator', function(eventAggregator){
eventAggregator.trigger('some.event.happens', {data: 'payload'});
}]);Testing
In order to run the unit tests, run bower install to get angular dependencies and npm install to get karma and related dependecies.
Run npm test to run the test suite.
0.0.1
10 years ago