Angular Client - AndersMalmgren/SignalR.EventAggregatorProxy GitHub Wiki
Deprecated uses Angular 1.x and SignalR 2.x
Install the Angular client using
Install-Package SignalR.EventAggregatorProxy.Client.Angular
The library wraps the vanilla client library so you need to add a reference to it.
Subscribe to events
angular.module("MyApp", ["signalR.eventAggregator"])
.controller("MyController", [
"$scope", "$http", function($scope, $http) {
function onEvent(e) {
//act on event
};
$scope.eventAggregator().subscribe(MyApp.MyEvent, onEvent);
}
]);
NOTE The wrapper listens to scope destroy event and unsubscribes the scope
Publish client side events
- First declare an event
MyApp.ClientEvent = function(data) {
this.data = data;
};
- Subscribe to it
$scope.eventAggregator().subscribe(MyApp.ClientEvent, onEvent);
- Publish
$scope.eventAggregator().publish(new MyApp.ClientEvent("data"));