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

Proposal: Extract LifecycleScopeProvider to separate artifact and make it implement ScopeProvider #197

Closed
ZacSweers opened this issue Apr 28, 2018 · 2 comments
Milestone

Comments

@ZacSweers
Copy link
Collaborator

Currently, LifecycleScopeProvider is a first class citizen in autodispose's API. I'd like to propose making it just an implementation of ScopeProvider, with preferably default handling to match the existing behavior. The goal is to simplify AutoDispose's API by reducing the surface area from 3 to 2 and allow use of LifecycleScopeProvider everywhere ScopeProvider is used.

This would be a major ish breaking change of the library, so we should decide this before 1.0

public interface LifecycleScopeProvider<E> extends ScopeProvider {
  Observable<E> lifecycle();
  E peekLifecycle();
  Function<E, E> correspondingEvents();
  
  // Java 8
  default Maybe<?> requestScope() {
    // LifecycleScopeUtil would be LifecycleScopeProvider utils extracted
    return LifecycleScopeUtil.deferredResolvedLifecycle(this);
  }
}

By default, we could keep it java 7 compatible and have a java 8 artifact that extends via DefaultLifecycleScopeProvider with the default implementation. Alternatively, if we rewrite in kotlin, we could allow it to handle it.

Open questions for discussion:

  1. Should we do this? If not, why not?
  2. Should we have a default artifact?
  3. If we did this in kotlin, should we still do Tweak RecordingObserver toString() #2 too with @JvmDefault?
@ZacSweers ZacSweers added this to the 1.0.0 milestone Apr 28, 2018
@ZacSweers
Copy link
Collaborator Author

We could actually do this in a non-breaking way until 1.0 by making the new artifact be a different package name (which we'd likely do anyway). Only difference is we'd want to make any implementers use the new artifacts relatively soon, probably in the same release.

@ZacSweers
Copy link
Collaborator Author

We plan to move forward with this. From a high level, there will be two new artifacts: one for the LifecycleScopeProvider, and another for the default implementation that targets java 8/desugar-friendly consumers.

The new artifact will be called autodispose-lifecycle, have a LifecycleScopes utility class with the lifecycle-specific utilities from ScopeUtil, LifecycleScopeProvider, and TestLifecycleScopeProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant