Skip to content

Instantly share code, notes, and snippets.

@a-ignatov-parc
Created March 25, 2013 08:54
Show Gist options
  • Save a-ignatov-parc/5235795 to your computer and use it in GitHub Desktop.
Save a-ignatov-parc/5235795 to your computer and use it in GitHub Desktop.
asyncTest('Context works normaly between to instances of one class', 1, function() {
var observatory = new window.WebApp.Observatory(),
TestClass = function() {
var count = this.count,
cid;
this.cid = cid = 'c' + count;
this.constructor.prototype.count++
this.init = function() {
observatory.on('test.' + this.cid, this.handler, this);
};
this.destroy = function() {
observatory.off('.' + this.cid);
};
this.init();
};
TestClass.prototype = {
constructor: TestClass,
handler: function() {
equal(this.cid, 'c0', 'context is ok');
},
count: 0
};
var a = new TestClass(),
b = new TestClass();
b.destroy();
b = null;
start();
observatory.trigger('test');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment