Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.

Commit 8333a1c

Browse files
committed
Merge branch 'canary'
Conflicts: CHANGELOG.md
2 parents a65d222 + 8e5006e commit 8333a1c

File tree

9 files changed

+91
-25
lines changed

9 files changed

+91
-25
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# angular-vertxbus [![Bower version](https://badge.fury.io/bo/angular-vertxbus.svg)](http://badge.fury.io/bo/angular-vertxbus) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
1+
# angular-vertxbus [![Bower version](https://badge.fury.io/bo/angular-vertxbus.svg)](http://badge.fury.io/bo/angular-vertxbus) [![npm version](https://badge.fury.io/js/angular-vertxbus.svg)](http://badge.fury.io/js/angular-vertxbus) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
22

33
Client side library using VertX Event Bus as an Angular Service module
44

@@ -134,12 +134,12 @@ For each connect or disconnect, a global broadcast will be emitted (on `$rootSco
134134

135135
### Setup for using same callback with different addresses
136136

137-
In some scenarios you will want to use a single callback definition to many different addresses. To do this you will
138-
have to follow this pattern.
137+
In some scenarios you will want to use a single callback definition to many different addresses. To do this you will
138+
have to follow this pattern.
139139

140140
Create a javascript object that defines your callback. Do not attempt to use `.prototype` as the methods defined
141141
as such will always point to the same memory allocation - so will always be found identical when adding to the internal
142-
array.
142+
array.
143143
```javascript
144144
function FunctionHolder(){
145145
"use strict";
@@ -151,7 +151,7 @@ function FunctionHolder(){
151151
};
152152
```
153153

154-
Then when adding the listeners, you will create a new instance of your object and use your defined function.
154+
Then when adding the listeners, you will create a new instance of your object and use your defined function.
155155
```javascript
156156
var funcHolder = new FunctionHolder();
157157
vertxEventBusService.addListener('address', funcHolder.handler);

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"author": "Jan Philipp",
33
"name": "angular-vertxbus",
4-
"description": "Seed for reusable Angular components.",
5-
"version": "0.8.1",
4+
"description": "AngularJS facade and service acting as a Vert.x SockJS client",
5+
"version": "0.9.0",
66
"homepage": "http://github.com/knalli/angular-vertxbus",
7-
"main": "./dist/angular-vertxbus.min.js",
7+
"main": "./dist/angular-vertxbus.js",
88
"ignore": [
99
".editorconfig",
1010
".jshintrc",
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"angular": "~1.2.0",
23-
"sockjs": "~0.3.4",
23+
"sockjs-client": "~0.3.4",
2424
"vertxbus.js": "http://cdnjs.cloudflare.com/ajax/libs/vertx/2.0.0/vertxbus.js"
2525
},
2626
"devDependencies": {

component.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "angular-vertxbus",
3+
"description": "AngularJS facade and service acting as a Vert.x SockJS client",
4+
"version": "master",
5+
"main": "dist/angular-vertxbus.js",
6+
"repository": "knalli/angular-vertxbus",
7+
"scripts": [
8+
"dist/angular-vertxbus.js"
9+
],
10+
"dependencies": {
11+
"components/angular.js": "~1.2.0"
12+
},
13+
"license": "MIT"
14+
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "angular-vertxbus",
3-
"version": "0.8.1",
4-
"description": "Seed for reusable Angular components.",
5-
"main": "dist/angular-vertxbus.min.js",
3+
"version": "0.9.0",
4+
"description": "AngularJS facade and service acting as a Vert.x SockJS client",
5+
"main": "dist/angular-vertxbus.js",
66
"scripts": {
77
"prepublish": "bower install",
88
"test": "grunt install-test && grunt test",

src/service.coffee

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
angular.module('knalli.angular-vertxbus')
2121
.provider('vertxEventBusService', () ->
2222

23+
CONSTANTS =
24+
MODULE: 'angular-vertxbus'
25+
COMPONENT: 'service'
26+
2327
DEFAULT_OPTIONS =
2428
loginRequired: false
2529
loginBlockForSession: false #NYI
@@ -88,16 +92,19 @@ angular.module('knalli.angular-vertxbus')
8892
@requireLogin = (value = options.loginRequired) ->
8993
options.loginRequired = value
9094
return this
95+
@requireLogin.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: requireLogin"
9196

9297
# private: NYI
9398
@blockForSession = (value = options.loginBlockForSession) ->
9499
options.loginBlockForSession = value
95100
return this
101+
@blockForSession.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: blockForSession"
96102

97103
# private: NYI
98104
@skipUnauthorizeds = (value = options.skipUnauthorizeds) ->
99105
options.skipUnauthorizeds = value
100106
return this
107+
@skipUnauthorizeds.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: skipUnauthorizeds"
101108

102109
@$get = ($rootScope, $q, $interval, $timeout, vertxEventBus) ->
103110
# Extract options (with defaults)
@@ -131,6 +138,7 @@ angular.module('knalli.angular-vertxbus')
131138
vertxEventBus.onclose = ->
132139
wrapped.getConnectionState(true)
133140
$rootScope.$broadcast "#{prefix}system.disconnected"
141+
vertxEventBus.onclose.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: 'onclose' handler"
134142

135143
ensureOpenConnection = (fn) ->
136144
if wrapped.getConnectionState() is vertxEventBus.EventBus.OPEN
@@ -140,20 +148,24 @@ angular.module('knalli.angular-vertxbus')
140148
messageQueueHolder.push(fn)
141149
return true
142150
return false
151+
ensureOpenConnection.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: ensureOpenConnection"
143152

144153
ensureOpenAuthConnection = (fn) ->
145154
unless options.loginRequired
146155
# easy: no login required
147156
ensureOpenConnection fn
148157
else
149-
ensureOpenConnection ->
158+
wrapFn = ->
150159
if validSession
151160
fn()
152161
return true
153162
else
154163
# ignore this message
155164
console.debug("[VertX EB Service] Message was not sent because login is required") if debugEnabled
156165
return false
166+
wrapFn.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: ensureOpenAuthConnection function wrapper"
167+
ensureOpenConnection wrapFn
168+
ensureOpenAuthConnection.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: ensureOpenAuthConnection"
157169

158170
# All utility methods working directly on the event bus object.
159171
# The object "vertxEventBus" must be available.
@@ -163,10 +175,11 @@ angular.module('knalli.angular-vertxbus')
163175
return unless typeof callback is 'function'
164176
console.debug("[VertX EB Service] Register handler for #{address}") if debugEnabled
165177
return fnWrapperMap.get(callback) if fnWrapperMap.containsKey(callback) # already known
166-
fnWrapperMap.put(callback, (message, replyTo) ->
178+
deconstructor = (message, replyTo) ->
167179
callback(message, replyTo)
168180
$rootScope.$digest()
169-
)
181+
deconstructor.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.registerHandler (deconstructor)"
182+
fnWrapperMap.put(callback, deconstructor)
170183
vertxEventBus.registerHandler address, fnWrapperMap.get(callback)
171184
# Remove a callback handler for the specified address match.
172185
unregisterHandler : (address, callback) ->
@@ -181,36 +194,48 @@ angular.module('knalli.angular-vertxbus')
181194
# @param timeout an optional number for a timout after which the promise will be rejected
182195
send : (address, message, timeout = 10000) ->
183196
deferred = $q.defer()
184-
dispatched = ensureOpenAuthConnection ->
197+
next = ->
185198
vertxEventBus.send address, message, (reply) ->
186199
if deferred then deferred.resolve reply
187200
# Register timeout for promise rejecting.
188201
if deferred then $timeout (-> deferred.reject()), timeout
202+
next.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.send (ensureOpenAuthConnection callback)"
203+
dispatched = ensureOpenAuthConnection next
189204
if deferred and !dispatched then deferred.reject()
190205
return deferred?.promise
191206
# Publish a message to the specified address (using EventBus.publish).
192207
# @param address a required string for the targeting address in the bus
193208
# @param message a required piece of message data
194209
publish : (address, message) ->
195-
dispatched = ensureOpenAuthConnection ->
210+
next = ->
196211
vertxEventBus.publish address, message
212+
next.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.publish (ensureOpenAuthConnection callback)"
213+
dispatched = ensureOpenAuthConnection next
197214
return dispatched
198215
# Send a login message
199216
# @param username
200217
# @param password
201218
# @param timeout
202219
login : (username, password, timeout = 5000) ->
203220
deferred = $q.defer()
204-
vertxEventBus.login username, password, (reply) ->
221+
next = (reply) ->
205222
if reply?.status is 'ok'
206223
deferred.resolve reply
207224
$rootScope.$broadcast "#{prefix}system.login.succeeded", (status: reply?.status)
208225
else
209226
deferred.reject reply
210227
$rootScope.$broadcast "#{prefix}system.login.failed", (status: reply?.status)
228+
next.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.login (callback)"
229+
vertxEventBus.login username, password, next
211230
$timeout (-> deferred.reject()), timeout
212231
return deferred.promise
213232

233+
util.registerHandler.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.registerHandler"
234+
util.unregisterHandler.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.unregisterHandler"
235+
util.send.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.send"
236+
util.publish.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.publish"
237+
util.login.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: util.login"
238+
214239
# Wrapping methods for the api
215240
wrapped =
216241
# Store of all handlers using as a cache when the event bus is not online
@@ -266,8 +291,18 @@ angular.module('knalli.angular-vertxbus')
266291
validSession = false
267292
return reply
268293

294+
wrapped.registerHandler.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.registerHandler"
295+
wrapped.unregisterHandler.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.unregisterHandler"
296+
wrapped.send.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.send"
297+
wrapped.publish.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.publish"
298+
wrapped.getConnectionState.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.getConnectionState"
299+
wrapped.isValidSession.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.isValidSession"
300+
wrapped.login.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: wrapped.login"
301+
269302
# Update the current connection state periodially.
270-
$interval (-> wrapped.getConnectionState(true)), sockjsStateInterval
303+
connectionIntervalCheck = -> wrapped.getConnectionState(true)
304+
connectionIntervalCheck.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: periodic connection check"
305+
$interval connectionIntervalCheck, sockjsStateInterval
271306

272307
### building and exposing the actual service API ###
273308
return (
@@ -284,6 +319,7 @@ angular.module('knalli.angular-vertxbus')
284319
isValidSession : -> validSession
285320
login : wrapped.login
286321
)
322+
@$get.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: initializer"
287323

288324
return #void
289325
)

src/wrapper.coffee

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
angular.module('knalli.angular-vertxbus')
1515
.provider('vertxEventBus', () ->
1616

17+
CONSTANTS =
18+
MODULE: 'angular-vertxbus'
19+
COMPONENT: 'wrapper'
20+
1721
DEFAULT_OPTIONS =
1822
enabled: true
1923
debugEnabled: false
@@ -123,17 +127,29 @@ angular.module('knalli.angular-vertxbus')
123127
registerHandler: (address, handler) ->
124128
eventBus.registerHandler(address, handler)
125129
### and return the deregister callback ###
126-
return ->
130+
deconstructor = ->
127131
stub.unregisterHandler(address, handler)
128132
return #void
133+
deconstructor.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.registerHandler (deconstructor)"
134+
return deconstructor
129135
unregisterHandler: (address, handler) -> eventBus.unregisterHandler(address, handler)
130136
readyState: -> eventBus.readyState()
131137
### expose current used internal instance of actual EventBus ###
132138
EventBus: EventBus_
133139
getOptions: -> angular.extend({}, options)
140+
stub.reconnect.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.reconnect"
141+
stub.close.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.close"
142+
stub.login.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.login"
143+
stub.send.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.send"
144+
stub.publish.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.publish"
145+
stub.registerHandler.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.registerHandler"
146+
stub.unregisterHandler.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.unregisterHandler"
147+
stub.readyState.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.readyState"
148+
stub.getOptions.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: EventBusWrapper.getOptions"
134149
else
135150
console.debug("[VertX EventBus] Disabled") if debugEnabled
136151
return stub
152+
@$get.displayName = "#{CONSTANTS.MODULE}/#{CONSTANTS.COMPONENT}: initializer"
137153

138154
return #void
139155
)

test/e2e/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<span ng-hide="sessionIsValid">Invalid Session</span>
2222
</div>
2323

24-
<script src="bower_components/sockjs/sockjs.js"></script>
24+
<script src="bower_components/sockjs-client/dist/sockjs.js"></script>
2525
<script src="bower_components/vertxbus.js/index.js"></script>
2626
<script src="bower_components/angular/angular.js"></script>
2727
<script src="temp/src/angular-vertxbus-adapter.js"></script>

test_scopes/angular_1.2.x/bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Jan Philipp",
33
"name": "angular-vertxbus",
4-
"description": "Seed for reusable Angular components.",
4+
"description": "",
55
"version": "0.0.0",
66
"homepage": "http://github.com/knalli/angular-vertxbus",
77
"repository": {
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"angular": "~1.2.0",
13-
"sockjs": "~0.3.4",
13+
"sockjs-client": "~0.3.4",
1414
"vertxbus.js": "http://cdnjs.cloudflare.com/ajax/libs/vertx/2.0.0/vertxbus.js"
1515
},
1616
"devDependencies": {

test_scopes/angular_1.3.x/bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Jan Philipp",
33
"name": "angular-vertxbus",
4-
"description": "Seed for reusable Angular components.",
4+
"description": "",
55
"version": "0.0.0",
66
"homepage": "http://github.com/knalli/angular-vertxbus",
77
"repository": {
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"angular": "~1.3.0",
13-
"sockjs": "~0.3.4",
13+
"sockjs-client": "~0.3.4",
1414
"vertxbus.js": "http://cdnjs.cloudflare.com/ajax/libs/vertx/2.0.0/vertxbus.js"
1515
},
1616
"devDependencies": {

0 commit comments

Comments
 (0)