Skip to content

vladgurovich/angular-event-aggregator

Repository files navigation

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.

About

$digest-free Event Aggregator for AngularJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published