-
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
RxLifecycle interop module #118
RxLifecycle interop module #118
Conversation
Looks like the build timed out. Looking into the log |
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.
Good start. Just a note for something I noticed in a few places. It should be spelled RxLifecycle
, not RXLifeCycle
. Please update that in any places I didn't comment on as well
|
||
private static final Object DEFAULT_THROWAWAY_OBJECT = new Object(); | ||
|
||
static <E> ScopeProvider bindLifecycle(final LifecycleProvider<E> provider) { |
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.
These methods should both be public
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.
On further thinking, I think we should call both of these methods from
for consistency with the rest of AutoDispose
* as normal terminal event. There is no mapping to {@link LifecycleEndedException} and in such | ||
* cases the stream is normally disposed </em> | ||
*/ | ||
public final class RXLifeCycleInterop { |
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.
This should be called RxLifecycleInterop
/** | ||
* Interop class for {@link RxLifecycle}. It provides static utility methods to convert {@link | ||
* LifecycleProvider} to {@link ScopeProvider} | ||
* <p> There are several static utility converter |
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: new line for the <p>
, remove the space after
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.
Quick check - What is the code style? My formatter did it automatically.
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.
code style is basically the square code style - https://github.com/square/java-code-styles
import io.reactivex.Maybe; | ||
|
||
/** | ||
* Interop class for {@link RxLifecycle}. It provides static utility methods to convert {@link |
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: don't link RxLifecycle since you're talking about the library and not the class. Same with the other link below
* LifecycleProvider#bindToLifecycle()} and {@link #bindUntilEvent(LifecycleProvider, Object)} for | ||
* {@link LifecycleProvider#bindUntilEvent(Object)} </p> | ||
* | ||
* <em>Unlike {@link AutoDispose}, {@link RxLifecycle} treats the {@link OutsideLifecycleException} |
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: remove the autodispose bit at the beginning
also, only make the beginning emphasized. Do something like:
<em>Note:</em> RxLifecycle treats...
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
public class RXLifeCycleInteropTest { |
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.
RxLifecycleInteropTest
} | ||
}; | ||
|
||
private LifeCycleProviderImpl lifeCycleProvider = new LifeCycleProviderImpl(); |
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.
lifecycleProvider
|
||
@Before | ||
public void setup() { | ||
lifeCycleProvider.onCreate(); |
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 mark this explicitly in each test
settings.gradle
Outdated
@@ -25,3 +25,5 @@ include ':autodispose' | |||
include ':autodispose-kotlin' | |||
include ':sample' | |||
include ':test-utils' | |||
include 'autodispose-rxlifecycle-interop' |
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 call this just autodispose-rxlifecycle
, and make the package name com.uber.autodispose.rxlifecycle
.
} | ||
|
||
@Test | ||
public void bindLifecycle_errorTermination_unsubscribe() { |
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 the method name say something about subscribing outside of lifecycle bounds?
@@ -25,7 +25,7 @@ dependencies { | |||
testApt deps.build.nullAway | |||
|
|||
compile project(':autodispose') | |||
compile 'com.trello.rxlifecycle2:rxlifecycle:2.2.0' | |||
api deps.rx.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.
this should be compile
as we're still on AGP 2.3.3
@@ -0,0 +1,3 @@ | |||
POM_NAME=AutoDispose (RXLifeCycle Interop) |
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.
RxLifecycle
@@ -0,0 +1,3 @@ | |||
POM_NAME=AutoDispose (RXLifeCycle Interop) | |||
POM_ARTIFACT_ID=autodispose-rxlifecycle-interop |
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.
autodispose-rxlifecycle
gradle/dependencies.gradle
Outdated
@@ -57,7 +57,8 @@ def misc = [ | |||
|
|||
def rx = [ | |||
android: 'io.reactivex.rxjava2:rxandroid:2.0.1', | |||
java: 'io.reactivex.rxjava2:rxjava:2.1.0' | |||
java: 'io.reactivex.rxjava2:rxjava:2.1.0', | |||
lifecycle: 'com.trello.rxlifecycle2:rxlifecycle:2.2.0' |
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.
this should be separate, this block is just for reactivex. Probably under misc
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.
Fixed top-level comments - renaming and dependencies.gradle in cbf3e10
FYI for future reference, it's much easier for the reviewer if you address each comment (± group of comments if they go together) in individual commits and link them in a reply, that way it's easy to connect the changes :) |
Will take care of it from future. |
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.
Almost there!
* methods such as {@link #bindLifecycle(LifecycleProvider)} for {@link | ||
* LifecycleProvider#bindToLifecycle()} and {@link #bindUntilEvent(LifecycleProvider, Object)} for | ||
* {@link LifecycleProvider#bindUntilEvent(Object)} </p> | ||
* Interop class for RxLifecycle. It provides static utility methods to convert {@link |
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: remove class
throw new AssertionError("No Instances"); | ||
} | ||
|
||
private static final Object DEFAULT_THROWAWAY_OBJECT = new Object(); | ||
|
||
static <E> ScopeProvider bindLifecycle(final LifecycleProvider<E> provider) { | ||
public static <E> ScopeProvider fromBindLifecycle(final LifecycleProvider<E> provider) { |
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 meant just call them from
, not fromBindLifecycle
or anything
*/ | ||
public final class RXLifeCycleInterop { | ||
public final class RXLifecycleInterop { |
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.
Rx
, not RX
import org.junit.Test; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
|
||
public class RXLifeCycleInteropTest { | ||
public class RXLifecycleInteropTest { |
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.
Rx
, not RX
* methods such as {@link #fromBindLifecycle(LifecycleProvider)} for {@link | ||
* LifecycleProvider#bindToLifecycle()} and {@link #fromBindUntilEvent(LifecycleProvider, Object)} for | ||
* {@link LifecycleProvider#bindUntilEvent(Object)}. | ||
* </p> |
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 this, add a <p>
below
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.
Fixed - 7c73cc2. Code review in github can be a pain.
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.
Much better than phabricator though! :)
@@ -1,3 +1,3 @@ | |||
POM_NAME=AutoDispose (RXLifeCycle Interop) | |||
POM_NAME=AutoDispose (RXLifecycle Interop) |
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.
RxLifecycle
@@ -79,7 +79,7 @@ public void bindLifecycle_outsideLifecycleBound_unsubscribe() { | |||
source.onNext(2); | |||
o.assertNoMoreEvents(); | |||
assertThat( | |||
source.hasObservers()).isFalse(); // Because RXLifeCycle treats lifecycle ended exception as terminal event. | |||
source.hasObservers()).isFalse(); // Because RXLifecycle treats lifecycle ended exception as terminal event. |
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.
RxLifecycle
gradle/dependencies.gradle
Outdated
@@ -52,13 +52,13 @@ def kotlin = [ | |||
def misc = [ | |||
errorProneAnnotations: "com.google.errorprone:error_prone_annotations:${versions.errorProne}", | |||
javaxExtras: "com.uber.javaxextras:javax-extras:0.1.0", | |||
jsr305: 'com.google.code.findbugs:jsr305:3.0.2' | |||
jsr305: 'com.google.code.findbugs:jsr305:3.0.2', | |||
lifecycle: 'com.trello.rxlifecycle2:rxlifecycle:2.2.0' |
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.
rxlifecycle
throw new AssertionError("No Instances"); | ||
} | ||
|
||
private static final Object DEFAULT_THROWAWAY_OBJECT = new Object(); | ||
|
||
public static <E> ScopeProvider fromBindLifecycle(final LifecycleProvider<E> provider) { | ||
public static <E> ScopeProvider fromLifecycle(final LifecycleProvider<E> provider) { |
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.
from(...)
. Same with the one below
@@ -28,7 +28,7 @@ private RxLifecycleInterop() { | |||
|
|||
private static final Object DEFAULT_THROWAWAY_OBJECT = new Object(); | |||
|
|||
public static <E> ScopeProvider fromLifecycle(final LifecycleProvider<E> provider) { | |||
public static <E> ScopeProvider from(final LifecycleProvider<E> provider) { |
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.
Missed this in my earlier comments, but these two methods should each have docs
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.
Fixed in c2e63ff
@@ -40,6 +56,22 @@ private RxLifecycleInterop() { | |||
}; | |||
} | |||
|
|||
/** | |||
* Converter for transforming {@link LifecycleProvider} to {@link 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.
Nit: fix the double space after for
in this and the one above
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.
Fixed - b373d42
For some weird reason - build is getting a timeout at accept license. - raw log. I am not making any change in the .travis.yml file. Master build on my fork is also facing the same issue. |
Licenses in the sdk seem to have changed. Can you try changing the travis yml file with the following patch?
|
*/ | ||
|
||
/** | ||
* Interop for RxLifecycle. |
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.
Please write a more detailed doc, this is the doc for the entire package
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.
Added more details and license - e463be6
Confirmed the above patch fixes it in #119. If you want to just include that in your PR that should fix it, and I'll close out the other one |
Merged that other one, just rebase your changes here |
Thanks. One quick question - do I need to copy license in each file or is it taken care of while pushing? |
Each file will need a license header yeah. You can install a profile into intelliJ to automatically add them |
@@ -15,7 +15,9 @@ | |||
*/ | |||
|
|||
/** | |||
* Interop for RxLifecycle. | |||
* Interop for RxLifecycle. It could understand RxLifecycle's |
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 think we can phrase this better, doesn't have to be too wordy. Let's do
AutoDispose extensions for interop with RxLifecycle. This namely supports {@link LifecycleProvider}.
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.
Fixed - 7f3e1a8
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.
Nice work! Pending CI results now :)
Thanks Harshit! |
RxLifecycle interop module added.
Resolves #82