Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pubsub scope issues with "this"? #6

Open
jonsykes opened this issue Jan 25, 2012 · 1 comment
Open

Pubsub scope issues with "this"? #6

jonsykes opened this issue Jan 25, 2012 · 1 comment

Comments

@jonsykes
Copy link

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.

@jonsykes
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant