You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.
As @JakeWharton mentioned here, we should define a common pattern for dealing with multi-callback listeners. There are many cases where this problem occurs (e.g. #382 or #351) and having a best-practice in place would help.
Take TextView.addTextChangedListener for example. The API could look like this
textView.addTextChangedListener(
on = { /* Handle changes ... */ },
after = { /* Handle changes ... */ }
)
with empty defaults for unused listeners.
Another option would be to add a function for every listener:
I don't think that's a use case we care about optimizing for. For the first style, in the exceedingly rare case that you want to remove only a single callback you would just invoke the function twice.
You are right, I did not think about that. I guess in that case the first option would be preferable, as it would only create one TextWatcher, whereas the second one would create two.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As @JakeWharton mentioned here, we should define a common pattern for dealing with multi-callback listeners. There are many cases where this problem occurs (e.g. #382 or #351) and having a best-practice in place would help.
Take
TextView.addTextChangedListener
for example. The API could look like thiswith empty defaults for unused listeners.
Another option would be to add a function for every listener:
The text was updated successfully, but these errors were encountered: