Skip to content

Commit

Permalink
Added javadoc for individual methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bangarharshit committed Oct 21, 2017
1 parent 8acd0e8 commit c2e63ff
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.OutsideLifecycleException;
import com.uber.autodispose.AutoDispose.ScopeHandler;
import com.uber.autodispose.LifecycleEndedException;
import com.uber.autodispose.ScopeProvider;
import io.reactivex.Maybe;
Expand All @@ -28,6 +29,21 @@ private RxLifecycleInterop() {

private static final Object DEFAULT_THROWAWAY_OBJECT = new Object();

/**
* Converter for transforming {@link LifecycleProvider} to {@link ScopeProvider}.
* It disposes the source when the next reasonable event occurs.
* <p>
* Example usage:
* <pre><code>
* Observable.just(1)
* .to(RxLifecycleInterop.from(lifecycleProvider))
* .subscribe(...)
* </code></pre>
*
* @param <E> the lifecycle event.
* @param provider the {@link LifecycleProvider} for RxLifecycle.
* @return a {@link ScopeHandler} to create AutoDisposing transformation
*/
public static <E> ScopeProvider from(final LifecycleProvider<E> provider) {
return new ScopeProvider() {
@Override public Maybe<?> requestScope() {
Expand All @@ -40,6 +56,22 @@ public static <E> ScopeProvider from(final LifecycleProvider<E> provider) {
};
}

/**
* Converter for transforming {@link LifecycleProvider} to {@link ScopeProvider}.
* It disposes the source when a specific event occurs.
* <p>
* Example usage:
* <pre><code>
* Observable.just(1)
* .to(RxLifecycleInterop.from(lifecycleProvider, event))
* .subscribe(...)
* </code></pre>
*
* @param <E> the lifecycle event.
* @param provider the {@link LifecycleProvider} for RxLifecycle.
* @param event the event at which the source is disposed.
* @return a {@link ScopeHandler} to create AutoDisposing transformation
*/
public static <E> ScopeProvider from(final LifecycleProvider<E> provider, final E event) {
return new ScopeProvider() {
@Override public Maybe<?> requestScope() {
Expand Down

0 comments on commit c2e63ff

Please sign in to comment.