bloody-jquery-plugins
bloody-jquery-plugins copied to clipboard
Pubsub scope issues with "this"?
regarding pubsub https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js
I was recently trying to use this within a class, by subscribing and then the callback was "this.handlerMethod" but when I fired the pub, the method was being fired, but if I console.log'ed the this value within the method it was now the topic class.
Not sure if that makes sense.
Just to explain my thought process a little more.
Doesn't this line
this.apply(d, args || []);
mean that the callback function we've stored is now called in the scope of "this", where "this" is the scope of the topic.publish object?