diff --git a/README.md b/README.md index 191cd16..1381903 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ And then to the module level `build.gradle.kts`: ``` dependencies { - implementation 'com.revolut.rxdata:dod:1.5.14' - implementation 'com.revolut.rxdata:core:1.5.14' - implementation 'com.revolut.rxdata:scheduler:1.5.14' + implementation 'com.revolut.rxdata:dod:1.5.15' + implementation 'com.revolut.rxdata:core:1.5.15' + implementation 'com.revolut.rxdata:scheduler:1.5.15' } ``` diff --git a/dfd/gradle.properties b/dfd/gradle.properties index ccba211..b03c216 100644 --- a/dfd/gradle.properties +++ b/dfd/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=dfd -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=dfd POM_PACKAGING=jar GROUP=com.revolut.flowdata diff --git a/dod-wrapper/gradle.properties b/dod-wrapper/gradle.properties index 7da1024..5980ad0 100644 --- a/dod-wrapper/gradle.properties +++ b/dod-wrapper/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=dod-wrapper -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=dod-wrapper POM_PACKAGING=jar GROUP=com.revolut.rxdata diff --git a/dod-wrapper/src/main/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapper.kt b/dod-wrapper/src/main/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapper.kt index 012abc9..81922f6 100644 --- a/dod-wrapper/src/main/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapper.kt +++ b/dod-wrapper/src/main/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapper.kt @@ -2,6 +2,7 @@ package com.revolut.rxdata.dod_wrapper import com.revolut.data.model.Data import com.revolut.rxdata.dod.DataObservableDelegate +import com.revolut.rxdata.dod.LoadingStrategy import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking import kotlinx.coroutines.rx2.asFlow @@ -63,10 +64,17 @@ class DataObservableDelegateWrapper( } ) + @Deprecated( + message = "please migrate to the method with the LoadingStrategy", + replaceWith = ReplaceWith("fun observe(params: Params, loadingStrategy: LoadingStrategy)") + ) fun observe(params: Params, forceReload: Boolean = true): Flow> = + observe(params, loadingStrategy = if (forceReload) LoadingStrategy.ForceReload else LoadingStrategy.Auto) + + fun observe(params: Params, loadingStrategy: LoadingStrategy): Flow> = inner.observe( params = params, - forceReload = forceReload, + loadingStrategy = loadingStrategy, ).asFlow() /** diff --git a/dod-wrapper/src/test/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapperTest.kt b/dod-wrapper/src/test/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapperTest.kt index b55189b..bb6de02 100644 --- a/dod-wrapper/src/test/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapperTest.kt +++ b/dod-wrapper/src/test/java/com/revolut/rxdata/dod_wrapper/DataObservableDelegateWrapperTest.kt @@ -2,6 +2,7 @@ package com.revolut.rxdata.dod_wrapper import app.cash.turbine.test import com.revolut.data.model.Data +import com.revolut.rxdata.dod.LoadingStrategy import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.Assertions.assertEquals @@ -42,7 +43,7 @@ class DataObservableDelegateWrapperTest { fun `GIVEN no data in memory and storage WHEN observe THEN return loading and network data`() = runTest { val delegate = createDelegate() - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(loading = true) awaitItem() shouldBe Data(content = networkResult) } @@ -56,7 +57,7 @@ class DataObservableDelegateWrapperTest { fromStorage = { throw IOException("No data") }, ) - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(loading = true) awaitItem() shouldBe Data(error = IOException("No data"), loading = true) awaitItem() shouldBe Data(content = networkResult) @@ -70,7 +71,7 @@ class DataObservableDelegateWrapperTest { storage[param] = storageResult val delegate = createDelegate() - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(loading = true) awaitItem() shouldBe Data(content = storageResult, loading = true) awaitItem() shouldBe Data(content = networkResult) @@ -84,7 +85,7 @@ class DataObservableDelegateWrapperTest { memoryCache[param] = memoryResult val delegate = createDelegate() - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) } } @@ -94,7 +95,7 @@ class DataObservableDelegateWrapperTest { memoryCache[param] = memoryResult val delegate = createDelegate() - delegate.observe(params = param, forceReload = true).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.ForceReload).test { awaitItem() shouldBe Data(content = memoryResult, loading = true) awaitItem() shouldBe Data(content = networkResult) } @@ -107,7 +108,7 @@ class DataObservableDelegateWrapperTest { fromNetwork = { throw IOException("Network error") }, ) - delegate.observe(params = param, forceReload = true).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.ForceReload).test { awaitItem() shouldBe Data(content = memoryResult, loading = true) awaitItem() shouldBe Data(content = memoryResult, error = IOException("Network error")) } @@ -119,7 +120,7 @@ class DataObservableDelegateWrapperTest { val delegate = createDelegate() val updatedValue = "Updated value" - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) delegate.updateAll(param, updatedValue) awaitItem() shouldBe Data(content = updatedValue) @@ -134,7 +135,7 @@ class DataObservableDelegateWrapperTest { val delegate = createDelegate() val updatedValue = "Updated value" - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) delegate.updateMemory(param, updatedValue) awaitItem() shouldBe Data(content = updatedValue) @@ -149,7 +150,7 @@ class DataObservableDelegateWrapperTest { val delegate = createDelegate() val updatedValue = "Updated value" - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) delegate.updateStorage(param, updatedValue) awaitItem() shouldBe Data(content = updatedValue) @@ -164,7 +165,7 @@ class DataObservableDelegateWrapperTest { val delegate = createDelegate() val updatedValue = "Updated value" - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) memoryCache[param] = updatedValue delegate.notifyFromMemory { true } @@ -178,7 +179,7 @@ class DataObservableDelegateWrapperTest { storage[param] = storageResult val delegate = createDelegate() - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) delegate.remove(param) awaitItem() shouldBe Data(content = null) @@ -193,7 +194,7 @@ class DataObservableDelegateWrapperTest { storage[param] = storageResult val delegate = createDelegate() - delegate.observe(params = param, forceReload = false).test { + delegate.observe(params = param, loadingStrategy = LoadingStrategy.Auto).test { awaitItem() shouldBe Data(content = memoryResult) delegate.reload(param) awaitItem() shouldBe Data(content = memoryResult, loading = true) diff --git a/dod/gradle.properties b/dod/gradle.properties index 53df000..85384f7 100644 --- a/dod/gradle.properties +++ b/dod/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=dod -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=dod POM_PACKAGING=jar GROUP=com.revolut.rxdata diff --git a/flow-extensions/gradle.properties b/flow-extensions/gradle.properties index a91f5dd..d3b0431 100644 --- a/flow-extensions/gradle.properties +++ b/flow-extensions/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=extensions -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=flow-core POM_PACKAGING=jar GROUP=com.revolut.flowdata diff --git a/model/gradle.properties b/model/gradle.properties index 1e63c7c..c0be780 100644 --- a/model/gradle.properties +++ b/model/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=model -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=data POM_PACKAGING=jar GROUP=com.revolut.data diff --git a/rx-extensions/gradle.properties b/rx-extensions/gradle.properties index 5a64e35..4a51fb4 100644 --- a/rx-extensions/gradle.properties +++ b/rx-extensions/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=extensions -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=core POM_PACKAGING=jar GROUP=com.revolut.rxdata diff --git a/scheduler/gradle.properties b/scheduler/gradle.properties index 70134b8..761bd7a 100644 --- a/scheduler/gradle.properties +++ b/scheduler/gradle.properties @@ -1,5 +1,5 @@ POM_ARTIFACT_ID=scheduler -VERSION_NAME=1.5.14 +VERSION_NAME=1.5.15 POM_NAME=scheduler POM_PACKAGING=aar GROUP=com.revolut.rxdata