-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ofEventListeners: added size() method. #6022
ofEventListeners: added size() method. #6022
Conversation
So I'll confess I don't know enough about this to give meaningful input. Looking at the current class though it seems like it isn't designed to be used granularly, where you can remove / disable individual listeners. I am guessing from arturo's response that is the intent. From what I can tell though Would it be better not to have |
oh sorry i read this as ofThreadChannel not ofEventListener. not sure we need this, the idea for ofEventListeners is just o have a quick way to remove several listeners at once at the end of the life of the container object. if you need more granularity than that then you can simple store them on a vector |
@arturoc 😄 Now your answer makes sense. As well I think that elliot was commenting something like this for the threaded channel as well so I understand your confusion, and sorry for confusing you. as @ofTheo says, it is essentially because there is |
I think @roymacdonald you could probably use the system in ofEasyCam like this:
So you use Also I think you can safely do: As the only data stored in ofEventListener is a unique_ptr so should be vector safe. But I think maybe |
yeah i think unsubscribe doesn't make any sense either. even with a size mehtod once you remove one listener the indices for the rest change so even if you know how many there are in total it's really hard to know what you are unsuibscribing. i would mark this as deprecated for next release and don't add anything else to this class |
Hi, I use the
But I'd like to have the following function as well:
So, for such I would need to add a |
totally agree @roymacdonald and @arturoc :) I think being able to know if you have already called unsubscribeAll() or not makes sense and as you said Roy it would be cleaner to track/use this way. Maybe you could add the deprecation note to this PR @roymacdonald ? |
@ofTheo sure. I'll add the deprecation note later today |
…ubscribe(size_t pos).
b66d716
to
a4f1737
Compare
@ofTheo just pushed a commit with the deprecation message and updated everything else to the current master |
i don't think that size is a good idea if we are not allowing access to the internals at all. perhaps |
makes a lot of sense. I'll change it for empty |
Thanks @roymacdonald ! |
* ofEventListeners: added empty() method and deprecation message for unsubscribe(size_t pos). #changelog #events
* ofEventListeners: added empty() method and deprecation message for unsubscribe(size_t pos). #changelog #events
This allows to things, checking not being out of bounds when removing a listener and checking if there are any registered listeners.
@arturoc @bakercp