Skip to content
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

Extract LifecycleScopeProvider to separate artifact #228

Merged
merged 46 commits into from
Jul 27, 2018

Conversation

ZacSweers
Copy link
Collaborator

@ZacSweers ZacSweers commented Jul 23, 2018

Resolves #197

This extracts LifecycleScopeProvider and its friends to a separate artifact and makes it extend ScopeProvider.

It's a bit long, but each commit is tiny and easy to digest.

Changes worth documenting:

  • LifecycleScopeProvider is now in a separate autodispose-lifecycle artifact and extends ScopeProvider. The package name is com.uber.autodispose.lifecycle.
  • AutoDisposePlugins has moved to AutoDisposeLifecyclePlugins since all the configuration was for lifecycle behavior. We can always bring AutoDisposePlugins back to the main artifact separately in the future.
  • OutsideLifecycleException is now OutsideScopeException, and was not moved to the new lifecycle artifact.
  • LifecycleEndNotification is no longer public
  • ScopeUtil's lifecycle-related methods are now moved to LifecycleScopes
  • TestLifecycleScopeProvider is moved to the new artifact
  • New autodispose-lifecycle-jdk8 artifact with a DefaultLifecycleScopeProvider that stubs a default implementation for requestScope()
  • New autodispose-lifecycle-ktx artifact with extension functions for LifecycleScopeProvider. This -ktx name will be applied to the other artifacts as well (planned before 1.0).
  • Deprecated APIs were not migrated from autodispose-main, as we're removing them
  • LifecycleScopeProvider changes:
    • correspondingEvents now returns a more specific Function called CorrespondingEventsFunction, which can only throw an OutsideScopeException and simplifies the generics
    • peekLifecycle is now annotated with RxJava's @Nullable rather than Jetbrains

@ZacSweers ZacSweers added this to the 1.0.0 milestone Jul 23, 2018
@ZacSweers ZacSweers self-assigned this Jul 23, 2018
import org.junit.Test;

import static com.google.common.truth.Truth.assertThat;

public final class AutoDisposeAndroidPluginsTest {

@After public void tearDown() {
@Before @After public void tearDown() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tearDown is probably a bad name if you're using this for before and after.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of Part of 53772ce

@@ -17,7 +33,7 @@
@Documented
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
@interface DoNotMock {
public @interface DoNotMock {
Copy link
Member

@tyvsmith tyvsmith Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid making this public, will show up on other folks classpaths and may be somewhat common?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked offline, not really avoidable unfortunately unless we wanted to make it a separate compileOnly artifact

import org.junit.Test;

import static com.google.common.truth.Truth.assertThat;

public final class AutoDisposePluginsTest {

@After public void tearDown() {
@Before @After public void tearDown() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other tearDown comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of 53772ce

*/
@CheckReturnValue
inline fun <T> Flowable<T>.autoDisposable(
provider: com.uber.autodispose.lifecycle.LifecycleScopeProvider<*>): FlowableSubscribeProxy<T>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce to class name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of 7fcd5a1

.autoDisposable(lifecycleScopeProvider)
.subscribe(o)

o.assertError { it is com.uber.autodispose.lifecycle.LifecycleNotStartedException }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of 7fcd5a1

lifecycleScopeProvider.stop()

// https://github.com/ReactiveX/RxJava/issues/5178
// assertThat(o.isDisposed).isTrue()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kill?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We leave these to indicate what we would assert/expect there but can't due to the linked issue

}

tasks.withType(JavaCompile) {
options.compilerArgs += ["-Xep:NullAway:ERROR", "-XepOpt:NullAway:AnnotatedPackages=com.uber"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract string to dedup?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside the scope of this PR


public final class LifecycleScopesTest {

// TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo for this diff?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

Copy link
Member

@tyvsmith tyvsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits, no big concerns.

@ZacSweers
Copy link
Collaborator Author

@kageiit @msridhar any clues to why the error-prone artifact would start failing on dependency mismatches from the changes here?

@ZacSweers ZacSweers merged commit 8b6e751 into master Jul 27, 2018
@ZacSweers ZacSweers deleted the z/lifecycleExtraction branch July 27, 2018 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants