angular-primus
Primus provider for Angular.
This plugin works with other Primus plugins like primus-emitter and primus-resource.
Install
Using bower
bower install angular-primus
Usage
angular.module('controllers.primus', ['primus'])
.config(function (primusProvider) {
primusProvider
.setEndpoint('http://mywebsite.com')
.setOptions({
reconnect: {
minDelay: 100,
maxDelay: 60000,
retries: 100
}
})
.setDefaultMultiplex(false);
})
.controller('PrimusCtrl', function ($scope, primus) {
primus.$on('data', function (data) {
$scope.data = data;
});
primus.write('hello');
primus.$on('customEvent', function (customData) {
$scope.customData = customData;
});
primus.send('customEvent', { foo: 'bar' });
primus.$resource('myResource').then(function (myResource) {
myResource.myMethod();
});
});
License
MIT