Skip to content
Anders Malmgren edited this page Oct 12, 2015 · 5 revisions

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 a 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"));
Clone this wiki locally