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

Commit a088972

Browse files
committed
Release 0.8.0
1 parent ad641b1 commit a088972

File tree

4 files changed

+177
-21
lines changed

4 files changed

+177
-21
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
<a name="v0.8.0"></a>
2+
## v0.8.0 (2014-10-16)
3+
4+
5+
#### Features
6+
7+
* **service:** use a simple map internally avoiding callbacks issues ([8a5bd54e](http://github.com/knalli/angular-vertxbus/commit/8a5bd54ef33d8cbc90dc139d693e34b3340f70c2))
8+
19
<a name="v0.7.1"></a>
210
### v0.7.1 (2014-09-19)
311

dist/angular-vertxbus.js

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! angular-vertxbus - v0.7.1 - 2014-09-19
1+
/*! angular-vertxbus - v0.8.0 - 2014-10-16
22
* http://github.com/knalli/angular-vertxbus
33
* Copyright (c) 2014 ; Licensed */
44
(function () {
@@ -219,7 +219,7 @@
219219
Note the additional configuration of the module itself.
220220
*/
221221
angular.module('knalli.angular-vertxbus').provider('vertxEventBusService', function () {
222-
var DEFAULT_OPTIONS, MessageQueueHolder, options;
222+
var DEFAULT_OPTIONS, MessageQueueHolder, SimpleMap, options;
223223
DEFAULT_OPTIONS = {
224224
loginRequired: false,
225225
loginBlockForSession: false,
@@ -251,6 +251,80 @@
251251
};
252252
return MessageQueueHolder;
253253
}();
254+
SimpleMap = function () {
255+
SimpleMap.prototype.keys = null;
256+
SimpleMap.prototype.values = null;
257+
function SimpleMap() {
258+
this.keys = [];
259+
this.values = [];
260+
}
261+
SimpleMap.prototype.put = function (key, value) {
262+
var idx;
263+
idx = this._indexForKey(key);
264+
if (idx > -1) {
265+
this.values[idx] = value;
266+
} else {
267+
this.keys.push(key);
268+
this.values.push(value);
269+
}
270+
return this;
271+
};
272+
SimpleMap.prototype._indexForKey = function (key) {
273+
var i, k, _i, _len, _ref;
274+
_ref = this.keys;
275+
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
276+
k = _ref[i];
277+
if (key === k) {
278+
return i;
279+
}
280+
}
281+
return -1;
282+
};
283+
SimpleMap.prototype._indexForValue = function (value) {
284+
var i, v, _i, _len, _ref;
285+
_ref = this.values;
286+
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
287+
v = _ref[i];
288+
if (value === v) {
289+
return i;
290+
}
291+
}
292+
return -1;
293+
};
294+
SimpleMap.prototype.containsKey = function (key) {
295+
var idx;
296+
idx = this._indexForKey(key);
297+
return idx > -1;
298+
};
299+
SimpleMap.prototype.containsValue = function (value) {
300+
var idx;
301+
idx = this._indexForValue(value);
302+
return idx > -1;
303+
};
304+
SimpleMap.prototype.get = function (key) {
305+
var idx;
306+
idx = this._indexForKey(key);
307+
if (idx > -1) {
308+
return this.values[idx];
309+
}
310+
return void 0;
311+
};
312+
SimpleMap.prototype.remove = function (key) {
313+
var idx;
314+
idx = this._indexForKey(key);
315+
if (idx > -1) {
316+
this.keys[idx] = void 0;
317+
this.values[idx] = void 0;
318+
}
319+
return void 0;
320+
};
321+
SimpleMap.prototype.clear = function () {
322+
this.keys = [];
323+
this.values = [];
324+
return this;
325+
};
326+
return SimpleMap;
327+
}();
254328
options = angular.extend({}, DEFAULT_OPTIONS);
255329
this.requireLogin = function (value) {
256330
if (value == null) {
@@ -286,7 +360,7 @@
286360
validSession = false;
287361
loginPromise = null;
288362
messageQueueHolder = new MessageQueueHolder(messageBuffer);
289-
fnWrapperMap = {};
363+
fnWrapperMap = new SimpleMap();
290364
if (enabled && vertxEventBus) {
291365
vertxEventBus.onopen = function () {
292366
var address, callback, callbacks, fn, _i, _len, _ref2;
@@ -353,14 +427,14 @@
353427
if (debugEnabled) {
354428
console.debug('[VertX EB Service] Register handler for ' + address);
355429
}
356-
if (fnWrapperMap[callback]) {
357-
return fnWrapperMap[callback];
430+
if (fnWrapperMap.containsKey(callback)) {
431+
return fnWrapperMap.get(callback);
358432
}
359-
fnWrapperMap[callback] = function (message, replyTo) {
433+
fnWrapperMap.put(callback, function (message, replyTo) {
360434
callback(message, replyTo);
361435
return $rootScope.$digest();
362-
};
363-
return vertxEventBus.registerHandler(address, fnWrapperMap[callback]);
436+
});
437+
return vertxEventBus.registerHandler(address, fnWrapperMap.get(callback));
364438
},
365439
unregisterHandler: function (address, callback) {
366440
if (typeof callback !== 'function') {
@@ -369,8 +443,8 @@
369443
if (debugEnabled) {
370444
console.debug('[VertX EB Service] Unregister handler for ' + address);
371445
}
372-
vertxEventBus.unregisterHandler(address, fnWrapperMap[callback]);
373-
fnWrapperMap[callback] = void 0;
446+
vertxEventBus.unregisterHandler(address, fnWrapperMap.get(callback));
447+
fnWrapperMap.remove(callback);
374448
},
375449
send: function (address, message, timeout) {
376450
var deferred, dispatched;

dist/angular-vertxbus.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)