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

Misc cleanup #146

Merged
merged 6 commits into from
Jul 12, 2020
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
8 changes: 4 additions & 4 deletions dispatch-android-lifecycle-extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SomeApplication : Application() {
override fun onCreate() {
super.onCreate()
// A custom factory can be set to add elements to the CoroutineContext
LifecycleScopeFactory.set { MainImmediateProvidedCoroutineContext() + SomeCustomElement() }
LifecycleScopeFactory.set { MainImmediateContext() + SomeCustomElement() }
}
}
```
Expand All @@ -68,7 +68,7 @@ class SomeEspressoTest {
@After
fun tearDown() {
// The factory can also be reset to default
LifecycleCoroutineScopeFactory.reset()
LifecycleScopeFactory.reset()
}
}
```
Expand All @@ -93,7 +93,7 @@ class SomeFragmentEspressoTest {
fun setUp() {
// set a custom factory which is applied to all newly created lifecycleScopes
LifecycleScopeFactory.set {
MainImmediateProvidedCoroutineContext() + idlingRule.dispatcherProvider
MainImmediateContext() + idlingRule.dispatcherProvider
}

// now SomeFragment will use an IdlingDispatcher in its CoroutineScope
Expand Down Expand Up @@ -142,7 +142,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7")
implementation("com.rickbusarow.dispatch:dispatch-android-lifecycle-extensions:1.0.0-beta04")

implementation("androidx.lifecycle:lifecycle-common:2.2.0")
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package samples
import dispatch.android.lifecycle.*
import dispatch.core.*

class LifecycleScopeSample {
class LifecycleScopeExtensionSample {

@Sample
fun lifecycleScopeSample() {
fun lifecycleScopeExtensionSample() {

// This could be any LifecycleOwner -- Fragments, Activities, Services...
class SomeFragment : Fragment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import kotlinx.coroutines.*
* The `viewModelScope` is automatically cancelled when the [LifecycleOwner]'s
* [lifecycle][LifecycleOwner.getLifecycle]'s [Lifecycle.State] drops to [Lifecycle.State.DESTROYED].
*
* @sample samples.LifecycleScopeSample.lifecycleScopeSample
* @sample samples.LifecycleScopeExtensionSample.lifecycleScopeExtensionSample
*/
val LifecycleOwner.lifecycleScope: LifecycleCoroutineScope
get() = LifecycleCoroutineScopeStore.get(this.lifecycle)
3 changes: 0 additions & 3 deletions dispatch-android-lifecycle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,5 @@ dependencies {
testImplementation(Libs.RickBusarow.Hermit.coroutines)
testImplementation(Libs.RickBusarow.Hermit.junit5)

testImplementation(Libs.RickBusarow.Hermit.coroutines)
testImplementation(Libs.RickBusarow.Hermit.junit5)

testImplementation(Libs.Robolectric.core)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* limitations under the License.
*/

@file:Suppress("EXPERIMENTAL_API_USAGE")

package samples

import dispatch.android.lifecycle.*
Expand Down Expand Up @@ -46,7 +44,8 @@ class LifecycleCoroutineScopeFactorySample {
}
}

private annotation class Before
private annotation class After
private annotation class Module
private annotation class Provides
internal annotation class Before
internal annotation class After
internal annotation class Module
internal annotation class Provides
internal annotation class Inject
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*

annotation class Inject

@CoroutineTest
@ExperimentalCoroutinesApi
class LifecycleCoroutineScopeSample(
Expand Down
4 changes: 2 additions & 2 deletions dispatch-core/src/main/java/dispatch/core/CoroutineScopes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ public fun MainCoroutineScope(
* @see CoroutineScope
*/
public fun MainImmediateCoroutineScope(
job: Job = SupervisorJob(), dispatcherProvider:
DispatcherProvider = DefaultDispatcherProvider()
job: Job = SupervisorJob(),
dispatcherProvider: DispatcherProvider = DefaultDispatcherProvider()
): MainImmediateCoroutineScope = object : MainImmediateCoroutineScope {
override val coroutineContext = job + dispatcherProvider.mainImmediate +
dispatcherProvider
Expand Down
8 changes: 4 additions & 4 deletions docs/kdoc/dispatch-android-lifecycle-extensions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SomeApplication : Application() {
override fun onCreate() {
super.onCreate()
// A custom factory can be set to add elements to the CoroutineContext
LifecycleScopeFactory.set { MainImmediateProvidedCoroutineContext() + SomeCustomElement() }
LifecycleScopeFactory.set { MainImmediateContext() + SomeCustomElement() }
}
}
```
Expand All @@ -65,7 +65,7 @@ class SomeEspressoTest {
@After
fun tearDown() {
// The factory can also be reset to default
LifecycleCoroutineScopeFactory.reset()
LifecycleScopeFactory.reset()
}
}
```
Expand All @@ -90,7 +90,7 @@ class SomeFragmentEspressoTest {
fun setUp() {
// set a custom factory which is applied to all newly created lifecycleScopes
LifecycleScopeFactory.set {
MainImmediateProvidedCoroutineContext() + idlingRule.dispatcherProvider
MainImmediateContext() + idlingRule.dispatcherProvider
}

// now SomeFragment will use an IdlingDispatcher in its CoroutineScope
Expand Down Expand Up @@ -139,7 +139,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7")
implementation("com.rickbusarow.dispatch:dispatch-android-lifecycle-extensions:1.0.0-beta04")

implementation("androidx.lifecycle:lifecycle-common:2.2.0")
}
```
Expand Down
8 changes: 4 additions & 4 deletions docs/modules/dispatch-android-lifecycle-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SomeApplication : Application() {
override fun onCreate() {
super.onCreate()
// A custom factory can be set to add elements to the CoroutineContext
LifecycleScopeFactory.set { MainImmediateProvidedCoroutineContext() + SomeCustomElement() }
LifecycleScopeFactory.set { MainImmediateContext() + SomeCustomElement() }
}
}
```
Expand All @@ -68,7 +68,7 @@ class SomeEspressoTest {
@After
fun tearDown() {
// The factory can also be reset to default
LifecycleCoroutineScopeFactory.reset()
LifecycleScopeFactory.reset()
}
}
```
Expand All @@ -93,7 +93,7 @@ class SomeFragmentEspressoTest {
fun setUp() {
// set a custom factory which is applied to all newly created lifecycleScopes
LifecycleScopeFactory.set {
MainImmediateProvidedCoroutineContext() + idlingRule.dispatcherProvider
MainImmediateContext() + idlingRule.dispatcherProvider
}

// now SomeFragment will use an IdlingDispatcher in its CoroutineScope
Expand Down Expand Up @@ -142,7 +142,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7")
implementation("com.rickbusarow.dispatch:dispatch-android-lifecycle-extensions:1.0.0-beta04")

implementation("androidx.lifecycle:lifecycle-common:2.2.0")
}
```
Expand Down