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

A few misc bits #116

Merged
merged 3 commits into from
Oct 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package com.uber.autodispose.android.lifecycle

import android.arch.lifecycle.Lifecycle
import android.arch.lifecycle.Lifecycle.Event
import android.arch.lifecycle.LifecycleOwner
import com.uber.autodispose.LifecycleScopeProvider
import io.reactivex.annotations.CheckReturnValue
import io.reactivex.functions.Function

/**
* Extension that returns a [LifecycleScopeProvider] for this [LifecycleOwner].
Expand All @@ -38,6 +40,15 @@ inline fun LifecycleOwner.scope(): LifecycleScopeProvider<*> = AndroidLifecycleS
inline fun LifecycleOwner.scope(untilEvent: Lifecycle.Event): LifecycleScopeProvider<*>
= AndroidLifecycleScopeProvider.from(this, untilEvent)

/**
* Extension that returns a [LifecycleScopeProvider] for this [LifecycleOwner].
*
* @param boundaryResolver function that resolves the event boundary.
*/
@CheckReturnValue
inline fun LifecycleOwner.scope(boundaryResolver: Function<Event, Event>): LifecycleScopeProvider<*>
= AndroidLifecycleScopeProvider.from(this, boundaryResolver)

/**
* Extension that returns a [LifecycleScopeProvider] for this [Lifecycle].
*/
Expand All @@ -52,3 +63,12 @@ inline fun Lifecycle.scope(): LifecycleScopeProvider<*> = AndroidLifecycleScopeP
@CheckReturnValue
inline fun Lifecycle.scope(untilEvent: Lifecycle.Event): LifecycleScopeProvider<*>
= AndroidLifecycleScopeProvider.from(this, untilEvent)

/**
* Extension that returns a [LifecycleScopeProvider] for this [Lifecycle].
*
* @param boundaryResolver function that resolves the event boundary.
*/
@CheckReturnValue
inline fun Lifecycle.scope(boundaryResolver: Function<Event, Event>): LifecycleScopeProvider<*>
= AndroidLifecycleScopeProvider.from(this, boundaryResolver)
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ public static AndroidLifecycleScopeProvider from(
return from(lifecycle, new UntilEventFunction(untilEvent));
}

/**
* Creates a {@link AndroidLifecycleScopeProvider} for Android Lifecycles.
*
* @param owner the owner to scope for.
* @param boundaryResolver function that resolves the event boundary.
* @return a {@link AndroidLifecycleScopeProvider} against this owner.
*/
public static AndroidLifecycleScopeProvider from(
LifecycleOwner owner,
Function<Lifecycle.Event, Lifecycle.Event> boundaryResolver) {
return from(owner.getLifecycle(), boundaryResolver);
}

/**
* Creates a {@link AndroidLifecycleScopeProvider} for Android Lifecycles.
*
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def versions = [
androidTest: '0.5',
archComponents: '1.0.0-rc1',
errorProne: '2.1.1',
kotlin: '1.1.50',
kotlin: '1.1.51',
support: '26.1.0'
]

Expand Down