From 9622f358644db9b96909e5e91c5af77a7f84033e Mon Sep 17 00:00:00 2001 From: Eldar Gabdullin Date: Tue, 4 Sep 2012 09:20:41 +0400 Subject: [PATCH] prevent leakage --- lib/box.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/box.js b/lib/box.js index b71c985..27f1c72 100644 --- a/lib/box.js +++ b/lib/box.js @@ -50,11 +50,11 @@ Box.prototype.execute = function (app) { this.isSync ? this.done(this.fn.call(proxy, get)) : this.fn.call(proxy, get, function (error, val) { - if (error) return app._raise(self.path, error) + if (error) return self.error(app, error) self.done(val) }) } catch (e) { - app._raise(this.path, e) + this.error(app, e) } } @@ -68,6 +68,11 @@ Box.prototype.done = function (val) { this.callbacks = null } +Box.prototype.error = function (app, err) { + this.callbacks = null + app._raise(this.path, err) +} + Box.prototype.onready = function (cb) { this.callbacks = this.callbacks || [] this.callbacks.push(cb)