-
Notifications
You must be signed in to change notification settings - Fork 638
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
Add bindView implementation and tests #12
Conversation
@dlew let me know if you want me to add tests for |
Was this mostly taken from the old RxAndroid repo? I think it looks good, but I'd like to take it a slightly different direction (implementation-wise). Right now it's lacking a bit in two ways:
I'd like it if we had a solution that's composed of two steps:
|
Yup, mostly taken from there. If you're open to depending on RxBinding though, I That's also be nice because then there wouldn't be any overlap between view
|
I don't mind depending on RxBinding for now. Worst-case scenario we could always spit it out as another module later. But honestly I think most people using RxAndroid will want RxBinding anyways. |
Agreed. Opened a PR there for attach events: JakeWharton/RxBinding#76 |
That PR is in RxBinding now, so I'll update this after its next release! Should I close it for now or just leave it open until then? |
Whatever you want to do. It doesn't much matter to me. |
Alright, I'll leave it open for now
|
Now that there's a new version of RxBinding out, would this be possible to do? |
Yup, I'll update it when I get the chance today or tomorrow. On Sun, Aug 23, 2015, 7:52 AM Daniel Lew notifications@github.com wrote:
|
@dlew rebased and updated with use of |
* @return a reusable {@link Observable.Transformer} that unsubscribes the source during the View lifecycle | ||
*/ | ||
public static <T> Observable.Transformer<T, T> bindView(final View view) { | ||
|
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.
Nit: Extra newlines.
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.
You want more newlines or to remove this? I was just matching the pattern I thought other functions were using here
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.
Remove - the others don't have an extra newline.
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.
We should add a sample at some point, doesn't have to be here, but if not here then we'll create an issue to track. |
Before, this would only work for "Object"s and not subclasses, such as Strings. This fixes that with some proper generics and adds a test for it
* @param lifecycle the lifecycle sequence of a View | ||
* @return a reusable {@link Observable.Transformer} that unsubscribes the source during the View lifecycle | ||
*/ | ||
public static <T, E> Observable.Transformer<T, T> bindView(final Observable<E> lifecycle) { |
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.
Should this be <E>
or <? extends E>
? I only ask because we're sort of copying takeUntil
and that's what they do (again, not exactly sure why since I suck at generics).
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.
Mimic Observable#takeUntil and use <? extends E>
.
Btw, this is the difference between the three:
Observable<E>
an Observable that only outputs E and exactly that.Observable<? extends E>
an Observable that outputs anything with an upperbound of E (so any descendant of E or E itself).Observable<?>
an Observable that outputs anything, can't use that here because the Operator (Transformer) expects a type!
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.
Done in e8fdbdb
Add bindView implementation and tests
👍 |
Also updated a couple dependencies along the way