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

Commit 806a931

Browse files
committed
Merge branch 'canary'
2 parents e9a0196 + db168ad commit 806a931

File tree

13 files changed

+89
-71
lines changed

13 files changed

+89
-71
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

Gruntfile.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ module.exports = function (grunt) {
176176
},
177177
'dist-withPolyfill' : {
178178
src : [
179-
'node_modules/babel-core/browser-polyfill.js',
179+
'node_modules/babel-polyfill/dist/polyfill.js',
180180
'dist/angular-vertxbus.js'
181181
],
182182
dest : 'dist/angular-vertxbus.withpolyfill.js'
@@ -226,7 +226,6 @@ module.exports = function (grunt) {
226226

227227
// Testing
228228
grunt.registerTask('test', [
229-
'clean',
230229
'eslint',
231230
'karma:unit'
232231
]);
@@ -246,17 +245,19 @@ module.exports = function (grunt) {
246245
]);
247246

248247
// Building & releasing
249-
grunt.registerTask('build', [
250-
'clean',
251-
'eslint',
252-
'karma:unit',
248+
grunt.registerTask('compile', [
253249
'browserify:dist',
254250
'concat:dist-withPolyfill',
255251
// 'extract_sourcemap:dist',// TODO enable sourcemaps
256252
// 'extract_sourcemap:dist-withPolyfill',// TODO enable sourcemaps
257253
'uglify:dist',
258254
'uglify:dist-withPolyfill'
259255
]);
256+
grunt.registerTask('build', [
257+
'clean',
258+
'test',
259+
'compile'
260+
]);
260261
grunt.registerTask('release', [
261262
'conventionalChangelog',
262263
'build'

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Jan Philipp",
33
"name": "angular-vertxbus",
44
"description": "AngularJS facade and service acting as a Vert.x SockJS client",
5-
"version": "3.1.0",
5+
"version": "3.2.0",
66
"homepage": "http://github.com/knalli/angular-vertxbus",
77
"main": "./dist/angular-vertxbus.js",
88
"keywords": [

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = function(config) {
4444

4545
// list of files / patterns to load in the browser
4646
files: [
47-
'node_modules/babel-core/browser-polyfill.js',
47+
'node_modules/babel-polyfill/dist/polyfill.js',
4848
injectByScope(scope, 'angular/angular.js'),
4949
injectByScope(scope, 'angular-mocks/angular-mocks.js'),
5050
'test/unit/mock/sockjs.js',

package.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-vertxbus",
3-
"version": "3.1.0",
3+
"version": "3.2.0",
44
"description": "AngularJS facade and service acting as a Vert.x SockJS client",
55
"main": "dist/angular-vertxbus.js",
66
"keywords": [
@@ -34,22 +34,25 @@
3434
},
3535
"license": "MIT",
3636
"devDependencies": {
37-
"babel": "^5.8.23",
38-
"babelify": "^6.2.0",
37+
"babel": "^6.0.14",
38+
"babel-cli": "^6.0.14",
39+
"babel-polyfill": "^6.0.14",
40+
"babel-preset-es2015": "^6.0.14",
41+
"babelify": "^7.0.2",
3942
"bower": "^1.5.3",
40-
"browserify": "^11.0.1",
43+
"browserify": "^12.0.1",
4144
"browserify-ngannotate": "^1.0.1",
4245
"browserify-shim": "^3.8.10",
43-
"eslint-plugin-angular": "^0.12.0",
46+
"eslint-plugin-angular": "^0.13.0",
4447
"estraverse": "^4.1.0",
4548
"express": "^4.13.3",
4649
"grunt": "~0.4.5",
47-
"grunt-babel": "^5.0.1",
50+
"grunt-babel": "^6.0.0",
4851
"grunt-bower-install-simple": "^1.1.4",
4952
"grunt-browserify": "^4.0.0",
5053
"grunt-contrib-clean": "~0.6.0",
5154
"grunt-contrib-concat": "^0.5.1",
52-
"grunt-contrib-uglify": "^0.9.2",
55+
"grunt-contrib-uglify": "^0.10.0",
5356
"grunt-contrib-watch": "~0.6.1",
5457
"grunt-conventional-changelog": "^5.0.0",
5558
"grunt-extract-sourcemap": "^0.1.16",
@@ -59,7 +62,7 @@
5962
"istanbul": "^0.4.0",
6063
"jasmine-core": "^2.3.4",
6164
"karma": "^0.13.11",
62-
"karma-babel-preprocessor": "^5.2.2",
65+
"karma-babel-preprocessor": "^6.0.1",
6366
"karma-browserify": "^4.3.0",
6467
"karma-chrome-launcher": "^0.2.1",
6568
"karma-coverage": "^0.5.2",

src/lib/VertxEventBusWrapperProvider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ let VertxEventBusWrapperProvider = function () {
202202
* @requires $log
203203
*/
204204
/* @ngInject */
205-
this.$get = ($timeout, $log) => {
205+
this.$get = ($timeout, $log, $q) => {
206206
// Current options (merged defaults with application-wide settings)
207207
let instanceOptions = angular.extend({}, DEFAULTS, options);
208208
if (instanceOptions.enabled && vertx && vertx.EventBus) {
@@ -218,12 +218,12 @@ let VertxEventBusWrapperProvider = function () {
218218
delete instanceOptions.urlServer;
219219
delete instanceOptions.urlPath;
220220

221-
return new EventBusAdapter(vertx.EventBus, $timeout, $log, instanceOptions);
221+
return new EventBusAdapter(vertx.EventBus, $timeout, $log, $q, instanceOptions);
222222
} else {
223223
if (instanceOptions.debugEnabled) {
224224
$log.debug('[Vert.x EB Stub] Disabled');
225225
}
226-
return new NoopAdapter(vertx.EventBus);
226+
return new NoopAdapter(vertx.EventBus, $q);
227227
}
228228
};
229229

src/lib/adapter/BaseAdapter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
export default class BaseAdapter {
22

3-
constructor() {
3+
constructor($q) {
4+
this.$q = $q;
45
}
56

67
configureConnection() {
78
}
89

910
connect() {
11+
return this.$q.reject();
1012
}
1113

1214
reconnect() {

src/lib/adapter/EventBusAdapter.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import ConnectionConfigHolder from './../support/ConnectionConfigHolder';
8282

8383
export default class EventBusAdapter extends BaseAdapter {
8484

85-
constructor(EventBus, $timeout, $log, {
85+
constructor(EventBus, $timeout, $log, $q, {
8686
enabled,
8787
debugEnabled,
8888
initialConnectEnabled,
@@ -91,11 +91,12 @@ export default class EventBusAdapter extends BaseAdapter {
9191
sockjsReconnectInterval,
9292
sockjsOptions
9393
}) {
94-
super();
94+
super($q);
9595
// actual EventBus type
9696
this.EventBus = EventBus;
9797
this.$timeout = $timeout;
9898
this.$log = $log;
99+
this.$q = $q;
99100
this.options = {
100101
enabled,
101102
debugEnabled,
@@ -121,15 +122,18 @@ export default class EventBusAdapter extends BaseAdapter {
121122
* @description
122123
* Reconfigure the connection details.
123124
*
124-
* @param {string} urlServer
125-
* @param {string} [urlPath=/eventbus]
125+
* @param {string} urlServer see {@link knalli.angular-vertxbus.vertxEventBusProvider#methods_useUrlServer vertxEventBusProvider.useUrlServer()}
126+
* @param {string} [urlPath=/eventbus] see {@link knalli.angular-vertxbus.vertxEventBusProvider#methods_useUrlPath vertxEventBusProvider.useUrlPath()}
126127
*/
127128
configureConnection(urlServer, urlPath = '/eventbus') {
128129
this.options.connectionConfig = new ConnectionConfigHolder({urlServer, urlPath});
129130
return this;
130131
}
131132

132133
connect() {
134+
// connect promise
135+
let deferred = this.$q.defer();
136+
// currently valid url
133137
let url = `${this.options.connectionConfig.urlServer}${this.options.connectionConfig.urlPath}`;
134138
if (this.options.debugEnabled) {
135139
this.$log.debug(`[Vert.x EB Stub] Enabled: connecting '${url}'`);
@@ -144,6 +148,7 @@ export default class EventBusAdapter extends BaseAdapter {
144148
if (angular.isFunction(this.onopen)) {
145149
this.onopen();
146150
}
151+
deferred.resolve();
147152
};
148153
// instance onClose handler
149154
this.instance.onclose = () => {
@@ -170,6 +175,7 @@ export default class EventBusAdapter extends BaseAdapter {
170175
this.$timeout((() => this.connect()), this.options.sockjsReconnectInterval);
171176
}
172177
};
178+
return deferred.promise;
173179
}
174180

175181
/**

src/lib/adapter/NoopAdapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import BaseAdapter from './BaseAdapter';
22

33
export default class NoopAdapter extends BaseAdapter {
44

5-
constructor(EventBus) {
6-
super();
5+
constructor(EventBus, $q) {
6+
super($q);
77
// actual EventBus type
88
this.EventBus = EventBus;
99
}

test/unit/binding/vertxEventBus.spec.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,26 @@
33

44
describe('integration of module::vertxEventBus', function () {
55

6-
beforeEach(module('knalli.angular-vertxbus'));
6+
beforeEach(angular.mock.module('knalli.angular-vertxbus'));
77

8-
beforeEach(module('knalli.angular-vertxbus', function ($provide) {
8+
beforeEach(angular.mock.module('knalli.angular-vertxbus', function ($provide) {
99
$provide.value('$log', window.console);
1010
}));
1111

12-
it('should have vertxEventBus', function () {
13-
inject(function (vertxEventBus) {
14-
expect(vertxEventBus).not.to.be(undefined);
15-
});
16-
});
12+
it('should have vertxEventBus', angular.mock.inject(function (vertxEventBus) {
13+
expect(vertxEventBus).not.to.be(undefined);
14+
}));
1715

1816
describe('vertxEventBus (w/ reconnect)', function () {
1917

2018
var vertxEventBus, $timeout, $rootScope, $log;
2119

22-
beforeEach(module('knalli.angular-vertxbus', function (vertxEventBusProvider) {
20+
beforeEach(angular.mock.module('knalli.angular-vertxbus', function (vertxEventBusProvider) {
2321
// Override (improve test running time)
2422
vertxEventBusProvider.useDebug(true).useSockJsReconnectInterval(2000);
2523
}));
2624

27-
beforeEach(inject(function (_vertxEventBus_, _$timeout_, _$rootScope_, _$log_) {
25+
beforeEach(angular.mock.inject(function (_vertxEventBus_, _$timeout_, _$rootScope_, _$log_) {
2826
vertxEventBus = _vertxEventBus_;
2927
$timeout = _$timeout_;
3028
$rootScope = _$rootScope_;
@@ -224,12 +222,12 @@ describe('integration of module::vertxEventBus', function () {
224222

225223
var vertxEventBus, $timeout, $rootScope, $log;
226224

227-
beforeEach(module('knalli.angular-vertxbus', function (vertxEventBusProvider) {
225+
beforeEach(angular.mock.module('knalli.angular-vertxbus', function (vertxEventBusProvider) {
228226
// Override (improve test running time)
229227
vertxEventBusProvider.useDebug(true).useSockJsReconnectInterval(2000).useReconnect(false);
230228
}));
231229

232-
beforeEach(inject(function (_vertxEventBus_, _$timeout_, _$rootScope_, _$log_) {
230+
beforeEach(angular.mock.inject(function (_vertxEventBus_, _$timeout_, _$rootScope_, _$log_) {
233231
vertxEventBus = _vertxEventBus_;
234232
$timeout = _$timeout_;
235233
$rootScope = _$rootScope_;
@@ -269,7 +267,7 @@ describe('integration of module::vertxEventBus', function () {
269267

270268
var vertxEventBus, $timeout, $rootScope, $log;
271269

272-
beforeEach(module('knalli.angular-vertxbus', function (vertxEventBusProvider) {
270+
beforeEach(angular.mock.module('knalli.angular-vertxbus', function (vertxEventBusProvider) {
273271
// Override (improve test running time)
274272
vertxEventBusProvider
275273
.useDebug(true)
@@ -278,7 +276,7 @@ describe('integration of module::vertxEventBus', function () {
278276
.disableAutoConnect();
279277
}));
280278

281-
beforeEach(inject(function (_vertxEventBus_, _$timeout_, _$rootScope_, _$log_) {
279+
beforeEach(angular.mock.inject(function (_vertxEventBus_, _$timeout_, _$rootScope_, _$log_) {
282280
vertxEventBus = _vertxEventBus_;
283281
$timeout = _$timeout_;
284282
$rootScope = _$rootScope_;
@@ -336,12 +334,19 @@ describe('integration of module::vertxEventBus', function () {
336334
expect(onopenCount).to.be(0); // should be not called!
337335
$log.debug('apply connection config..');
338336
vertxEventBus.configureConnection('http://localhost:1234', '/eventbus1');
339-
vertxEventBus.connect();
337+
var connectPromise = vertxEventBus.connect();
338+
expect(connectPromise).not.to.be(undefined);
339+
var connectPromiseResult = false;
340+
connectPromise.then(() => {
341+
connectPromiseResult = true
342+
});
340343
setTimeout(function () {
344+
$rootScope.$digest(); // for $q
341345
$log.debug('check..');
342346
expect(SockJS.currentMockInstance.url).to.be('http://localhost:1234/eventbus1');
343347
expect(onopenCount).to.be(1);
344348
expect(oncloseCount).to.be(0);
349+
expect(connectPromiseResult ).to.be(true);
345350
done();
346351
}, 1200);
347352
}, 200);

0 commit comments

Comments
 (0)