Last active
September 12, 2017 07:37
-
-
Save jbro-io/7576616 to your computer and use it in GitHub Desktop.
Global event dispatcher/listener utility for AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('EventUtil', []) | |
.factory('broadcast', ['$rootScope', function($rootScope){ | |
return function(eventName, payload){ | |
$rootScope.$broadcast(eventName, payload); | |
}; | |
}]) | |
.factory('listen', ['$rootScope', function($rootScope){ | |
return function(eventName, listener){ | |
$rootScope.$on(eventName, listener); | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is so trivial there's no reason for it to exist.