Skip to content

Commit ff2b178

Browse files
committed
Access to signal R context. Add Constellation CDN for js lib. Promise on init context
1 parent 5ef0f17 commit ff2b178

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ The config process is managed by the fantastic library [node-config]. You can ma
5151
```js
5252
var constellation = require('constellation-nodejs');
5353

54+
//// Init and wait until initialization is completed
55+
constellation.init().then(function() {
56+
//// Init OK
57+
});
58+
5459
//// Listen activity
5560
constellation.consumerHub.connection.stateChanged(function (change) {
56-
if (change.newState === $.signalR.connectionState.connected) {
61+
if (change.newState === constellation.$.signalR.connectionState.connected) {
5762
console.log("Je suis connecté");
5863
}
5964
});

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ var ConstellationContext = require('./lib/constellation.js');
1111

1212
//// Checking config before init
1313
var context = new ConstellationContext();
14-
module.exports = context.check().init();
14+
module.exports = context.check();

lib/constellation.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const window = jsdom.jsdom().defaultView;
1616
const cdn = {
1717
jquery : 'http://code.jquery.com/jquery-2.2.2.min.js',
1818
signalr : 'http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.0.min.js',
19-
constellation : 'https://gist.githubusercontent.com/gclem/148a32553d7c5d8dbc081eda65361177/raw/5ed718d829cf72d87dc3a9811c4a2ef40ff3bbbb/constellation-js-%s.js'
19+
constellation : 'https://cdn.myconstellation.io/js/Constellation-%s.js'
2020
};
2121

2222
var ConstellationContext = function ()
@@ -45,10 +45,8 @@ var ConstellationContext = function ()
4545
this.init = function() {
4646
var that = this;
4747
this.loadConfig();
48-
this.loadDomContext()
48+
return this.loadDomContext()
4949
.then(function() { that.createHub(that.url, that.accessKey, that.applicationName, that.sdkVersion); });
50-
51-
return that;
5250
};
5351

5452
this.loadConfig = function() {
@@ -86,7 +84,7 @@ var ConstellationContext = function ()
8684
};
8785

8886
this.createHub = function (url, accessKey, appName) {
89-
var $ = window.$;
87+
var $ = this.$ = window.$;
9088
this.consumerHub = this.consumerHub || $.signalR.createConstellationConsumer(url, accessKey, appName);
9189

9290
return this.consumerHub;

0 commit comments

Comments
 (0)