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

Commit

Permalink
Release 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
knalli committed Oct 16, 2014
1 parent ad641b1 commit a088972
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 21 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<a name="v0.8.0"></a>
## v0.8.0 (2014-10-16)


#### Features

* **service:** use a simple map internally avoiding callbacks issues ([8a5bd54e](http://github.com/knalli/angular-vertxbus/commit/8a5bd54ef33d8cbc90dc139d693e34b3340f70c2))

<a name="v0.7.1"></a>
### v0.7.1 (2014-09-19)

Expand Down
94 changes: 84 additions & 10 deletions dist/angular-vertxbus.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! angular-vertxbus - v0.7.1 - 2014-09-19
/*! angular-vertxbus - v0.8.0 - 2014-10-16
* http://github.com/knalli/angular-vertxbus
* Copyright (c) 2014 ; Licensed */
(function () {
Expand Down Expand Up @@ -219,7 +219,7 @@
Note the additional configuration of the module itself.
*/
angular.module('knalli.angular-vertxbus').provider('vertxEventBusService', function () {
var DEFAULT_OPTIONS, MessageQueueHolder, options;
var DEFAULT_OPTIONS, MessageQueueHolder, SimpleMap, options;
DEFAULT_OPTIONS = {
loginRequired: false,
loginBlockForSession: false,
Expand Down Expand Up @@ -251,6 +251,80 @@
};
return MessageQueueHolder;
}();
SimpleMap = function () {
SimpleMap.prototype.keys = null;
SimpleMap.prototype.values = null;
function SimpleMap() {
this.keys = [];
this.values = [];
}
SimpleMap.prototype.put = function (key, value) {
var idx;
idx = this._indexForKey(key);
if (idx > -1) {
this.values[idx] = value;
} else {
this.keys.push(key);
this.values.push(value);
}
return this;
};
SimpleMap.prototype._indexForKey = function (key) {
var i, k, _i, _len, _ref;
_ref = this.keys;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
k = _ref[i];
if (key === k) {
return i;
}
}
return -1;
};
SimpleMap.prototype._indexForValue = function (value) {
var i, v, _i, _len, _ref;
_ref = this.values;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
v = _ref[i];
if (value === v) {
return i;
}
}
return -1;
};
SimpleMap.prototype.containsKey = function (key) {
var idx;
idx = this._indexForKey(key);
return idx > -1;
};
SimpleMap.prototype.containsValue = function (value) {
var idx;
idx = this._indexForValue(value);
return idx > -1;
};
SimpleMap.prototype.get = function (key) {
var idx;
idx = this._indexForKey(key);
if (idx > -1) {
return this.values[idx];
}
return void 0;
};
SimpleMap.prototype.remove = function (key) {
var idx;
idx = this._indexForKey(key);
if (idx > -1) {
this.keys[idx] = void 0;
this.values[idx] = void 0;
}
return void 0;
};
SimpleMap.prototype.clear = function () {
this.keys = [];
this.values = [];
return this;
};
return SimpleMap;
}();
options = angular.extend({}, DEFAULT_OPTIONS);
this.requireLogin = function (value) {
if (value == null) {
Expand Down Expand Up @@ -286,7 +360,7 @@
validSession = false;
loginPromise = null;
messageQueueHolder = new MessageQueueHolder(messageBuffer);
fnWrapperMap = {};
fnWrapperMap = new SimpleMap();
if (enabled && vertxEventBus) {
vertxEventBus.onopen = function () {
var address, callback, callbacks, fn, _i, _len, _ref2;
Expand Down Expand Up @@ -353,14 +427,14 @@
if (debugEnabled) {
console.debug('[VertX EB Service] Register handler for ' + address);
}
if (fnWrapperMap[callback]) {
return fnWrapperMap[callback];
if (fnWrapperMap.containsKey(callback)) {
return fnWrapperMap.get(callback);
}
fnWrapperMap[callback] = function (message, replyTo) {
fnWrapperMap.put(callback, function (message, replyTo) {
callback(message, replyTo);
return $rootScope.$digest();
};
return vertxEventBus.registerHandler(address, fnWrapperMap[callback]);
});
return vertxEventBus.registerHandler(address, fnWrapperMap.get(callback));
},
unregisterHandler: function (address, callback) {
if (typeof callback !== 'function') {
Expand All @@ -369,8 +443,8 @@
if (debugEnabled) {
console.debug('[VertX EB Service] Unregister handler for ' + address);
}
vertxEventBus.unregisterHandler(address, fnWrapperMap[callback]);
fnWrapperMap[callback] = void 0;
vertxEventBus.unregisterHandler(address, fnWrapperMap.get(callback));
fnWrapperMap.remove(callback);
},
send: function (address, message, timeout) {
var deferred, dispatched;
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-vertxbus.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a088972

Please sign in to comment.