Skip to content

Instantly share code, notes, and snippets.

@SimplGy SimplGy/angularEventBus.js
Last active Aug 29, 2015

What would you like to do?
Angular decoration makes $rootScope an event bus that cleans up after itself automaticaly. From:
$provide.decorator('$rootScope', ['$delegate', function($rootScope) {
$rootScope.prototype.$onRootScope = function(eventName, callback) {
var unbind = $rootScope.$on(eventName, callback);
this.$on('$destroy', unbind);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.