angular-event-aggregator

$digest-free Event Aggregator for AngularJS

Angular Core Dependency: ~1.2

Module License: MIT

Added by: Sam Deering

GitHub

Repository

vladgurovich/angular-event-aggregator

Stats

Stars: 6

Watchers: 6

Forks: 3

Module Description

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.

Module stats last updated: 2015-06-28 11:00:00

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!