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

Question about .on vs .once #3

Closed
malkomalko opened this issue Sep 18, 2014 · 3 comments
Closed

Question about .on vs .once #3

malkomalko opened this issue Sep 18, 2014 · 3 comments

Comments

@malkomalko
Copy link

I've been playing around with the library, and after reading up on the README it looks like anytime you use .on vs .once for anything (in my case KVO), you have to push the listener into an array.

I was trying out .on without pushing on an array and everything looked fine. Can you explain a little more how this works out, and why I shouldn't be using .on without pushing into an array? Also, is there any cleanup I have to do for .on instead of .once?

Thanks

@aleclarson
Copy link
Owner

Everything works correctly now! That was a regression in v3.0 so thanks a lot! 👍

@malkomalko
Copy link
Author

Hey @aleclarson can you explain what was a regression? Basically, if I use .on for anything, store the callback in an array, and do nothing else? Or do you mean everything works correctly in that I can use .on and .once in the same way?

Cheers,

Awesome library btw.

@aleclarson
Copy link
Owner

Glad you like it! Check out my other Swift repos, they might help you out. 😄

Any Listener you create using on() must be retained. Otherwise, it's released at the end of your function. This was just fixed in v3.1 to work as expected. 👍

Any Listener created with once() is retained for you! So fire and forget.

Thanks for making an issue, @malkomalko!

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

2 participants