-
Notifications
You must be signed in to change notification settings - Fork 226
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 additional extension methods for android-archcomponents #348
Conversation
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.
Let's add one for View as well in this PR
* subscription will be disposed. | ||
*/ | ||
@CheckReturnValue | ||
inline fun <T> Flowable<T>.autoDisposable(lifecycleOwner: LifecycleOwner, untilEvent: Event): FlowableSubscribeProxy<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.
Let's default the untilEvent to something sensible and then just have one overload?
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.
Can we really default an untilEvent
reliably for everyone? Usually the untilEvent
is inferred from when in the lifecycle you subscribe. However that inference logic is private in AndroidLifecycleScopeProvider
.
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.
I'd be fine with it package private
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.
Thought about it but I meant to keep that file as a dumping ground for testing Kotlin compatibility. When I add the |
Works for me! |
...mponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/KotlinExtensionsTest.kt
Outdated
Show resolved
Hide resolved
...mponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/KotlinExtensionsTest.kt
Outdated
Show resolved
Hide resolved
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.
LGTM! Couple nits
One thing I think we should check - what happens in the case of, say, an AppCompatActivity
that implements LifecycleOwner
and ScopeProvider
?
...mponents/src/androidTest/java/com/uber/autodispose/android/lifecycle/KotlinExtensionsTest.kt
Outdated
Show resolved
Hide resolved
...s/src/main/java/com/uber/autodispose/android/lifecycle/internal/CorrespondingEventsUtil.java
Outdated
Show resolved
Hide resolved
@@ -31,7 +33,7 @@ import java.util.concurrent.TimeUnit | |||
* Test Activity class to verify compilation of various extension functions. | |||
*/ | |||
@Ignore("Since it's only used to verify compilation of the extension functions") | |||
class TestKotlinActivity : AppCompatActivity() { | |||
class TestKotlinActivity : AppCompatActivity(), ScopeProvider { |
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.
Just to doubly confirm - it doesn't get confused about ambiguous types here if targeting this now?
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, it doesn't. Basically, it will always just resolve to one of those extension functions. It will ask you for one of them. If you're overloading with the untilEvent
, it will always resolve to the one with LifecycleOwner
.
...roid-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/KotlinExtensions.kt
Show resolved
Hide resolved
...roid-archcomponents/src/main/java/com/uber/autodispose/android/lifecycle/KotlinExtensions.kt
Outdated
Show resolved
Hide resolved
Couple nits but LGTM! |
Part of #347
I've added an additional
TestKotlinActivity
in thesample
just to test out the compilation of extension methods.