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
Reverted some View and Widget Observables to use simple objects instead of Event objects #100
Conversation
import rx.android.internal.Assertions; | ||
import rx.functions.Action0; | ||
|
||
class OnSubscribeTextViewInput2<T extends TextView> implements Observable.OnSubscribe<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numbering classes... ick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the 2 suffix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because there's already OnSubscribeTextViewInput
. This class is an implementation detail so the ugly "2" can be removed when the former is deleted.
It doesn't make sense to have multiple nearly identical API calls that are subtly different enough to confuse people. I'd rather go one way or the other, but not this both solution (especially since it involves numbering classes). |
We really should strongly define a style/code guide. PRs have started becoming bikeshed style discussions. |
Well, it's not so much bike shedding as it is just that this should be automated. I think keeping a consistent style is hugely important especially with like a dozen PRs coming in every week. I neither have the time nor would I take it if I had it to manually review every code style flaw. That's what tools exist for. I think @JakeWharton already worked on this? I saw a checkstyle template somewhere. It just needs adding to the build. |
@mttkay I did not mean to communicate that this PR is bikeshedding, rather that I've noticed that a lack of style guide can help lead to situations like these. It is especially easy for stuff like this to happen when a project moves fast and there isn't a central authority on style leading to slow divergence. |
What was everyone's thoughts on this? Should this go in? I don't have a strong opinion on it. |
I strongly disagree that we should have two versions of the same thing in the library. I think it's best to be opinionated. Otherwise the library just becomes confusing. I'm fine if we decide the simpler version (shown here) is the right version, but we shouldn't have both. |
I agree with Dan. Either one, but not both. @JakeWharton you have any thoughts? |
} | ||
|
||
static class CachedListeners { | ||
private static final Map<View, CompositeOnClickListener> sCachedListeners = new WeakHashMap<View, CompositeOnClickListener>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No 's' prefix
I think I prefer the more simple ones. There's definitely compelling reasons to just do a breaking API change here. And yes I need to get checkstyle in here ASAP. I'll do it separately so as to avoid dealing with all the build issues at once. |
objects instead of immutable events; changed corresponding tests back as well.
I have addressed all of issues, pointed out by @JakeWharton. Digit suffixes replaced by |
|
@dlew, well, all my code still uses 4 versions old RxAndroid, because the compatibility gets broken every release :( |
That's by design.
|
@Alexander-- you're using a pre-release version of a library, that has to be expected. What's the alternative you suggest? We shouldn't hesitate to change this while we're in stage where it's still okay to do exactly that. RxJava core saw dozens of breaking changes on the road to 1.0. That's I guess that cost we have to pay for using alpha level software, but ultimately, it's healthy for the library. |
If you are so strongly compelled to remove few backward compatible paths from this PR, do it already (I am, however, still going to include them in future ones). |
First of all - we can't edit your PR.
I'm trying to make sure I understand this correctly - are you saying that you will keep submitting PRs to re-add any code that we're talking about removing here? |
You can clone his branch, make the changes, amend to his commit, merge to master, and push to the remote. Then you get the author info but you become the committer. I do this all the time for cleaning up other people's PR as well as squashing. It's super annoying. |
@JakeWharton That is convoluted, depressing, and something I hope we can avoid unless necessary. |
I don't plan to spam you, unless you ask for it yourself :) I am going to deprecate things (when possible and makes sense) instead of removing them, as I stated in #94.
Alternatively to merge this pull request into master locally you can do git fetch git://github.com/Alexander--/RxAndroid.git "0.x" && git merge --no-ff --no-commit FETCH_HEAD
perform any changes you want as part of merge commit, and push the changes. IIRC, you can also use git fetch origin refs/pull/100/head:pr/100 && git merge --no-ff --no-commit FETCH_HEAD
not sure if this was ever documented by Github developers themselves. |
Yes that's what I do except on a branch. I have a bash alias that does everything for me. |
This library is still in infancy and in the interest of a clean API in the future we should not be afraid of breaking changes. The least impactful time to remove things is now. The API is in flux and will continue to be in that state for a while. We should remove old code instead of deprecating it. If you really need backwards compatibility then don't upgrade until you are ready to, or fork. Neither is a good option admittedly. |
Per #172 we have removed the view binding observables for the next release. |
Recent changes to UI observables (particularly, 406bf68) added number of POJO event classes as well as some of associated infrastructure. Some of those were really useful, but few others: click, text change and toggle (aka "input") event classes look forced, as if those were added solely to match style of similar methods. Unfortunately, as explained below, they aren't very useful and accomplish nothing, except adding redundant entities and increasing range of possible issues.
Few possible uses for event classes, that come to mind are:
reduce
on it. None of the event classes in question (except OnSubscribeTextViewInput) contain any useful state. Click and compound button switch are self-descriptive. CharSequence, returned byTextView.getText()
, can be mutable, and as such, is dangerous to use, unless immediately converted to string (which means, that at least onemap
call have to be done anyway).timestamp
operator for this.This merge request adds back Observables with tests and corresponding static methods, emitting plain View, TextView and Boolean objects. It also deprecates event-based methods. While we are at it, I have also renamed "input" to "toggle" as original naming choice was just plain bad.