I am using spine javascript library for a standalone javascript application. I heavily use the publisher/subscriber model and bind proxied callbacks to spine models. When I try to unbind a proxied callback, it doesnt unbind it. This happens only with proxied callbacks. A demo code
var Listener = Spine.Model.sub({
onChange : function(){this.log("Hooray!!")},
log:function(msg){console.log("Rxed event"+msg);},
bind: function(){SomeModel.bind("onChange",this.proxy(this.onChange));},
unBind:function(){SomeModel.unbind("onChange",this.proxy(this.onChange));}
});
var listener = new Listener();
when listener.bind()
is called it binds it correctly and callbacks are correct.
but when listener.unBind()
is called, the unbind doesnt happen.
If the callback was not proxied, it works but I need the correct context for the callback and so I need to proxy it.
Any help would be greatly appreciated.