From b97546654c1d7543ba53b8126f42b7d3c1758d2b Mon Sep 17 00:00:00 2001 From: mramotar Date: Wed, 18 Oct 2023 11:45:05 -0400 Subject: [PATCH] Rename to launchPagingStore Signed-off-by: mramotar_dbx --- .../{LaunchStore.kt => LaunchPagingStore.kt} | 14 +++++++------- ...unchStoreTests.kt => LaunchPagingStoreTests.kt} | 8 ++++---- .../store/paging5/PagingTests.kt | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) rename paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/{LaunchStore.kt => LaunchPagingStore.kt} (93%) rename paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/{LaunchStoreTests.kt => LaunchPagingStoreTests.kt} (93%) diff --git a/paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchStore.kt b/paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStore.kt similarity index 93% rename from paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchStore.kt rename to paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStore.kt index 1b8d7f647..c58c7afcc 100644 --- a/paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchStore.kt +++ b/paging/src/commonMain/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStore.kt @@ -19,7 +19,7 @@ private class StopProcessingException : Exception() * @param stream A lambda that invokes [Store.stream]. * @return A read-only [StateFlow] reflecting the state of the Store. */ -private fun , Output : StoreData> launchStore( +private fun , Output : StoreData> launchPagingStore( scope: CoroutineScope, keys: Flow, stream: (key: Key) -> Flow>, @@ -66,27 +66,27 @@ private fun , Output : StoreData> launchStore( /** * Initializes and returns a [StateFlow] that reflects the state of the [Store], updating by a flow of provided keys. - * @see [launchStore]. + * @see [launchPagingStore]. */ -fun , Output : StoreData> Store.launchStore( +fun , Output : StoreData> Store.launchPagingStore( scope: CoroutineScope, keys: Flow, ): StateFlow> { - return launchStore(scope, keys) { key -> + return launchPagingStore(scope, keys) { key -> this.stream(StoreReadRequest.fresh(key)) } } /** * Initializes and returns a [StateFlow] that reflects the state of the [Store], updating by a flow of provided keys. - * @see [launchStore]. + * @see [launchPagingStore]. */ @OptIn(ExperimentalStoreApi::class) -fun , Output : StoreData> MutableStore.launchStore( +fun , Output : StoreData> MutableStore.launchPagingStore( scope: CoroutineScope, keys: Flow, ): StateFlow> { - return launchStore(scope, keys) { key -> + return launchPagingStore(scope, keys) { key -> this.stream(StoreReadRequest.fresh(key)) } } diff --git a/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/LaunchStoreTests.kt b/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStoreTests.kt similarity index 93% rename from paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/LaunchStoreTests.kt rename to paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStoreTests.kt index eb8358e58..2de2aa0e4 100644 --- a/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/LaunchStoreTests.kt +++ b/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/LaunchPagingStoreTests.kt @@ -14,7 +14,7 @@ import kotlin.test.assertEquals import kotlin.test.assertIs @OptIn(ExperimentalStoreApi::class) -class LaunchStoreTests { +class LaunchPagingStoreTests { private val testScope = TestScope() private val userId = "123" @@ -34,7 +34,7 @@ class LaunchStoreTests { fun `state transitions from Loading to Loaded Collection for valid Cursor key`() = testScope.runTest { val key = PostKey.Cursor("1", 10) val keys = flowOf(key) - val stateFlow = store.launchStore(this, keys) + val stateFlow = store.launchPagingStore(this, keys) stateFlow.test { val state1 = awaitItem() @@ -52,7 +52,7 @@ class LaunchStoreTests { val key1 = PostKey.Cursor("1", 10) val key2 = PostKey.Cursor("11", 10) val keys = flowOf(key1, key2) - val stateFlow = store.launchStore(this, keys) + val stateFlow = store.launchPagingStore(this, keys) stateFlow.test { val state1 = awaitItem() @@ -77,7 +77,7 @@ class LaunchStoreTests { fun `state remains consistent if the same key is emitted multiple times`() = testScope.runTest { val key = PostKey.Cursor("1", 10) val keys = flowOf(key, key) - val stateFlow = store.launchStore(this, keys) + val stateFlow = store.launchPagingStore(this, keys) stateFlow.test { val state1 = awaitItem() diff --git a/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/PagingTests.kt b/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/PagingTests.kt index 7bbf8f56f..e4555e665 100644 --- a/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/PagingTests.kt +++ b/paging/src/commonTest/kotlin/org/mobilenativefoundation/store/paging5/PagingTests.kt @@ -27,7 +27,7 @@ class PagingTests { val key2 = PostKey.Cursor("11", 10) val keys = flowOf(key1, key2) - val stateFlow = store.launchStore(this, keys) + val stateFlow = store.launchPagingStore(this, keys) stateFlow.test { val initialState = awaitItem() assertIs(initialState)