Skip to content

Commit

Permalink
A few misc bits (#116)
Browse files Browse the repository at this point in the history
* Update to kotlin 1.1.51

* Add missing from(owner, boundaryResolver) for Owners

* Add kotlin extensions for boundaryResolver overloads
  • Loading branch information
ZacSweers authored Oct 21, 2017
1 parent a955826 commit 0e543ef
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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

0 comments on commit 0e543ef

Please sign in to comment.