diff --git a/static/hogfather.js b/static/hogfather.js index 1238723..a6a6eab 100644 --- a/static/hogfather.js +++ b/static/hogfather.js @@ -21,13 +21,22 @@ * @constructor * @param {Cosmopolite} cosmo * @param {string} name - * @param {function()} onReady */ -var Hogfather = function(cosmo, name, onReady) { - cosmo.getProfile().then(function(profile_id) { - this.prefix_ = '/hogfather/' + profile_id + '/' + name + '/'; - onReady(); - }.bind(this)); +var Hogfather = function(cosmo, name) { + this.cosmo_ = cosmo; + this.name_ = name; + + this.cosmo_.getProfile().then(this.onProfile_.bind(this)); +}; + + +/** + * @param {string} profile_id + */ +Hogfather.prototype.onProfile_ = function(profile_id) { + this.prefix_ = '/hogfather/' + profile_id + '/' + this.name_ + '/'; + this.cosmo_.subscribe(this.prefix_ + 'control'); + console.log(this.prefix_); }; diff --git a/static/test.js b/static/test.js index 03b65ea..9aac6ed 100644 --- a/static/test.js +++ b/static/test.js @@ -949,10 +949,14 @@ QUnit.module('Hogfather'); QUnit.asyncTest('Construct/shutdown', function(assert) { assert.expect(4); + var cosmo = new Cosmopolite(null, randstring()); assert.ok(true, 'new Cosmopolite() succeeds'); - var hogfather = new Hogfather(cosmo, randstring(), function() { + var hogfather = new Hogfather(cosmo, randstring()); + assert.ok(true, 'new Hogfather()) succeeds'); + + window.setTimeout(function() { hogfather.shutdown(); assert.ok(true, 'Hogfather.shutdown() succeeds'); @@ -960,6 +964,6 @@ QUnit.asyncTest('Construct/shutdown', function(assert) { assert.ok(true, 'Cosmopolite.shutdown() succeeds'); QUnit.start(); - }); - assert.ok(true, 'new Hogfather()) succeeds'); + }, 10 * 1000); + });