BaseChannel
d7-services.commons
An abstract notification channel. This service enables you to publish and subscribe data over events in a very fast and efficient way.
publish an event only to $rootScope using $rootScope.$emit
| Param | Type | Details |
|---|---|---|
| eventName | String | The events name |
| args | object | The events arguments |
publish data with event
angular
.module('myModule', ['d7-services.commons.d7-services.commons.baseChannel'])
.controller('myController', function ($scope,BaseChannel) {
BaseChannel.pubRootEmit('MY_EVENT', {my:'args'});
}
subscribe for an event published over $rootScope.$emit(event, args)
| Param | Type | Details |
|---|---|---|
| eventName | String |
|
| _Scope | Object |
|
| scopeHandler | function |
|
| mapArgs | function |
|
| function | The unsubscribe function from the $rootScope.on() call |
subscribe to an event
angular
.module('myModule', ['d7-services.commons.d7-services.commons.baseChannel'])
.controller('myController',function ($scope,BaseChannel) {
var unsubscribeHandler = BaseChannel.subRootEmit('MY_EVENT', $scope, function(args) {...}, function(args){return args;});
}