Created
June 19, 2015 21:39
-
-
Save unixunion/fd2df62d5b3e11b0d260 to your computer and use it in GitHub Desktop.
angular-vertxbus duplicate messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global angular:false,console:false */ | |
(function () { | |
'use strict'; | |
angular.module('app', ['ng', 'knalli.angular-vertxbus']) | |
.config(function(vertxEventBusProvider) { | |
vertxEventBusProvider | |
.useDebug(true) | |
.useUrlServer('http://localhost:8080'); | |
}) | |
.run(function ($rootScope, vertxEventBus, vertxEventBusService, $interval) { | |
$rootScope.sessionIsValid = false; | |
$rootScope.$on('vertx-eventbus.system.login.succeeded', function (event, data) { | |
console.log('Vert.X Login succeeded (status)', data); | |
$rootScope.sessionIsValid = (data && data.status === 'ok'); | |
}); | |
$rootScope.$on('vertx-eventbus.system.login.failed', function (event, data) { | |
console.log('Vert.X Login failed (status)', data); | |
$rootScope.sessionIsValid = false; | |
}); | |
$rootScope.$on('vertx-eventbus.system.connected', function(event, data) { | |
var holder = {}; | |
holder.timeServiceDeconstructor = vertxEventBusService.on('what-time-is-it', function (data) { | |
console.log("what time is it2 "); | |
}); | |
}); | |
$rootScope.moduleStats = { | |
wrapper: {}, | |
service: {} | |
}; | |
$interval(function () { | |
try { | |
$rootScope.moduleStats.wrapper.readyState = vertxEventBus.readyState(); | |
$rootScope.moduleStats.service.readyState = vertxEventBusService.readyState(); | |
$rootScope.moduleStats.service.getConnectionState = vertxEventBusService.getConnectionState(); | |
$rootScope.moduleStats.service.isEnabled = vertxEventBusService.isEnabled(); | |
$rootScope.moduleStats.service.isConnected = vertxEventBusService.isConnected(); | |
} catch (e) {} | |
}, 1000); | |
}) | |
.filter('eventBusState', function () { | |
var states = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; | |
return function (value) { | |
return states[value] || value; | |
}; | |
}) | |
.controller('MyController', function($scope, vertxEventBusService) { | |
$scope.login = function (username, password) { | |
vertxEventBusService.login(username, password) | |
.then(function (reply) { | |
$scope.reply = reply; | |
}) | |
['catch'](function (reply) { | |
$scope.reply = reply; | |
}); | |
}; | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment