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

Implement as()-based converter API #140

Closed
ZacSweers opened this issue Nov 27, 2017 · 0 comments
Closed

Implement as()-based converter API #140

ZacSweers opened this issue Nov 27, 2017 · 0 comments

Comments

@ZacSweers
Copy link
Collaborator

ZacSweers commented Nov 27, 2017

From the beginning, the ideal case has been for AutoDispose to be able to have a single point of entry API. to() unfortunately made this hard since each API accepted the same Function type with different generics. After contributing custom interfaces support in ReactiveX/RxJava#5729 though, the road ahead is clear.

The plan would be for AutoDispose to remain in pre-stable until as() is promoted to stable API (possibly in RxJava 2.2).

The implementation would be straightfoward. There would be a static "entry point" method with overloads for different scopes. Under the hood they would each just return an OmniConverter that implements all the converter interfaces. This would be the "final" API of AutoDispose for 1.0

Open question - What should the "entry point" method be named?

In java 8, you won't need the generic, which means you could have APIs like this:

Observable.just(1)
    .as(autoDisposable(scope))
    .subscribe();

For Java 7, you need the generic, and subsequently can't static import the method:

Observable.just(1)
    .as(AutoDispose.<Integer>autoDisposable(scope))
    .subscribe();

Note: In IntelliJ 2017.3, the generic above will autocomplete

In the Java 7 case above, it feels a bit... redundant? Idk. It might also be nice to unify this name and the kotlin extension functions, which are currently all autodisposeWith

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