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

matrix_client: Allow dynamic removal of listeners #78

Merged
merged 1 commit into from
Jan 18, 2017

Conversation

galpressman
Copy link
Contributor

Adding listeners is an action that cannot be reversed, while many users
need the ability to dynamically change whether they want to listen or not.
This patch assigns each listener with a unique id which allows users to
use it as a later reference for the same listener in case they want to
remove it.
This infrastructure can also be used in future commits to allow modifying
of listeners on-the-go.

Signed-off-by: Gal Pressman galpressman@gmail.com

Adding listeners is an action that cannot be reversed, while many users
need the ability to dynamically change whether they want to listen or not.
This patch assigns each listener with a unique id which allows users to
use it as a later reference for the same listener in case they want to
remove it.
This infrastructure can also be used in future commits to allow modifying
of listeners on-the-go.

Signed-off-by: Gal Pressman <galpressman@gmail.com>
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

@galpressman
Copy link
Contributor Author

Just to clarify, this does not break backwards compatibility.
Users with code based on old add_listener without the reference will obviously not be influenced by this patch. The uid is an addition with optional use.

@Half-Shot
Copy link
Collaborator

Ok to test

@galpressman
Copy link
Contributor Author

We can also do it the "stupid" (more simple) way of providing the callback pointer as a parameter and remove it from the list, what do you like more?

@Half-Shot
Copy link
Collaborator

This solution seems fine to me actually. In the future, I'd like to condense the code a little because I just feel there is a tad too much repetition, but for now this will do.

@Half-Shot Half-Shot merged commit 107ea7d into matrix-org:master Jan 18, 2017
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

Successfully merging this pull request may close these issues.

3 participants