Skip to content

Commit

Permalink
Release 5.1.0-alpha01 (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-ramotar authored Jan 25, 2024
1 parent c3950a1 commit cf9d9b1
Show file tree
Hide file tree
Showing 26 changed files with 34 additions and 30 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,17 @@

### Including Store In Your Project

> **Note**
>
> **[AtomicFU](https://github.com/Kotlin/kotlinx-atomicfu) is required ([#503](https://github.com/MobileNativeFoundation/Store/issues/503))**
#### Android
```kotlin
implementation "org.mobilenativefoundation.store:store5:5.0.0"
implementation "org.jetbrains.kotlinx:atomicfu:0.18.5"
implementation "org.mobilenativefoundation.store:store5:5.1.0-alpha01"
```

#### Multiplatform (Common, JVM, Native, JS)

```kotlin
commonMain {
dependencies {
implementation("org.mobilenativefoundation.store:store5:5.0.0")
implementation("org.jetbrains.kotlinx:atomicfu:0.18.5")
implementation("org.mobilenativefoundation.store:store5:5.1.0-alpha01")
}
}
```
Expand Down Expand Up @@ -128,7 +122,7 @@ store.clear(key)
### License

```text
Copyright (c) 2022 Mobile Native Foundation.
Copyright (c) 2024 Mobile Native Foundation.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
```
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ buildscript {
classpath(libs.maven.publish.plugin)
classpath(libs.kover.plugin)
classpath(libs.atomic.fu.gradle.plugin)
classpath(libs.molecule.gradle.plugin)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mobilenativefoundation.store.store5
package org.mobilenativefoundation.store.core5

/**
* Marks declarations that are still **experimental** in store API.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.mobilenativefoundation.store.core5

@ExperimentalStoreApi
enum class InsertionStrategy {
APPEND,
PREPEND,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.mobilenativefoundation.store.core5

@ExperimentalStoreApi
interface KeyProvider<Id : Any, Single : StoreData.Single<Id>> {
fun fromCollection(key: StoreKey.Collection<Id>, value: Single): StoreKey.Single<Id>
fun fromSingle(key: StoreKey.Single<Id>, value: Single): StoreKey.Collection<Id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package org.mobilenativefoundation.store.core5
* Every item that implements the [StoreData] interface must have a means of identification.
* This is useful in scenarios when data can be represented as singles or collections.
*/

@ExperimentalStoreApi
interface StoreData<out Id : Any> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.mobilenativefoundation.store.core5
* Provides mechanisms for ID-based fetch, page-based fetch, and cursor-based fetch.
* Includes options for sorting and filtering.
*/
@ExperimentalStoreApi
interface StoreKey<out Id : Any> {

/**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G

# POM file
GROUP=org.mobilenativefoundation.store
VERSION_NAME=5.1.0-SNAPSHOT
VERSION_NAME=5.1.0-alpha01
POM_PACKAGING=pom
POM_DESCRIPTION = Store5 is a Kotlin Multiplatform network-resilient repository layer

Expand Down
1 change: 0 additions & 1 deletion paging/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ kotlin {
implementation(project(":store"))
implementation(project(":cache"))
implementation(compose.runtime)
implementation(libs.molecule.runtime)
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.StoreData
import org.mobilenativefoundation.store.core5.StoreKey
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.MutableStore
import org.mobilenativefoundation.store.store5.Store
import org.mobilenativefoundation.store.store5.StoreReadRequest
Expand All @@ -27,6 +27,7 @@ private class StopProcessingException : Exception()
* @param stream A lambda that invokes [Store.stream].
* @return A read-only [StateFlow] reflecting the state of the Store.
*/
@ExperimentalStoreApi
private fun <Id : Any, Key : StoreKey<Id>, Output : StoreData<Id>> launchPagingStore(
scope: CoroutineScope,
keys: Flow<Key>,
Expand Down Expand Up @@ -73,6 +74,7 @@ private fun <Id : Any, Key : StoreKey<Id>, Output : StoreData<Id>> launchPagingS
* Initializes and returns a [StateFlow] that reflects the state of the [Store], updating by a flow of provided keys.
* @see [launchPagingStore].
*/
@ExperimentalStoreApi
fun <Id : Any, Key : StoreKey<Id>, Output : StoreData<Id>> Store<Key, Output>.launchPagingStore(
scope: CoroutineScope,
keys: Flow<Key>,
Expand All @@ -86,7 +88,7 @@ fun <Id : Any, Key : StoreKey<Id>, Output : StoreData<Id>> Store<Key, Output>.la
* Initializes and returns a [StateFlow] that reflects the state of the [Store], updating by a flow of provided keys.
* @see [launchPagingStore].
*/
@OptIn(ExperimentalStoreApi::class)
@ExperimentalStoreApi
fun <Id : Any, Key : StoreKey<Id>, Output : StoreData<Id>> MutableStore<Key, Output>.launchPagingStore(
scope: CoroutineScope,
keys: Flow<Key>,
Expand All @@ -96,6 +98,7 @@ fun <Id : Any, Key : StoreKey<Id>, Output : StoreData<Id>> MutableStore<Key, Out
}
}

@ExperimentalStoreApi
private fun <Id : Any, Key : StoreKey.Collection<Id>, Output : StoreData<Id>> joinData(
key: Key,
prevResponse: StoreReadResponse<Output>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.mobilenativefoundation.store.paging5.util.PostDatabase
import org.mobilenativefoundation.store.paging5.util.PostKey
import org.mobilenativefoundation.store.paging5.util.PostPutRequestResult
import org.mobilenativefoundation.store.paging5.util.PostStoreFactory
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.MutableStore
import org.mobilenativefoundation.store.store5.StoreReadRequest
import org.mobilenativefoundation.store.store5.StoreReadResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.mobilenativefoundation.store.cache5.StoreMultiCache
import org.mobilenativefoundation.store.core5.KeyProvider
import org.mobilenativefoundation.store.core5.StoreKey
import org.mobilenativefoundation.store.store5.Converter
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.Fetcher
import org.mobilenativefoundation.store.store5.MutableStore
import org.mobilenativefoundation.store.store5.SourceOfTruth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.reactivex.Flowable
import kotlinx.coroutines.rx2.asFlowable
import kotlinx.coroutines.rx2.rxCompletable
import kotlinx.coroutines.rx2.rxSingle
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.Store
import org.mobilenativefoundation.store.store5.StoreBuilder
import org.mobilenativefoundation.store.store5.StoreReadRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.mobilenativefoundation.store.rx2.getSingle
import org.mobilenativefoundation.store.rx2.ofMaybe
import org.mobilenativefoundation.store.rx2.ofResultSingle
import org.mobilenativefoundation.store.rx2.withScheduler
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.Fetcher
import org.mobilenativefoundation.store.store5.FetcherResult
import org.mobilenativefoundation.store.store5.SourceOfTruth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.mobilenativefoundation.store.rx2.observeClearAll
import org.mobilenativefoundation.store.rx2.ofMaybe
import org.mobilenativefoundation.store.rx2.ofResultSingle
import org.mobilenativefoundation.store.rx2.withScheduler
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.Fetcher
import org.mobilenativefoundation.store.store5.FetcherResult
import org.mobilenativefoundation.store.store5.SourceOfTruth
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.mobilenativefoundation.store.store5

import org.mobilenativefoundation.store.core5.ExperimentalStoreApi

interface Clear {
interface Key<Key : Any> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.mobilenativefoundation.store.store5

import org.mobilenativefoundation.store.core5.ExperimentalStoreApi

@ExperimentalStoreApi
interface MutableStore<Key : Any, Output : Any> :
Read.StreamWithConflictResolution<Key, Output>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ interface StoreBuilder<Key : Any, Output : Any> {
memoryCache
)

fun <Key : Any, Network : Any, Output : Any, Local: Any> from(
fun <Key : Any, Network : Any, Output : Any, Local : Any> from(
fetcher: Fetcher<Key, Network>,
sourceOfTruth: SourceOfTruth<Key, Local, Output>,
converter: Converter<Network, Local, Output>
Expand All @@ -96,7 +96,7 @@ interface StoreBuilder<Key : Any, Output : Any> {
converter
)

fun <Key : Any, Network : Any, Output : Any, Local: Any> from(
fun <Key : Any, Network : Any, Output : Any, Local : Any> from(
fetcher: Fetcher<Key, Network>,
sourceOfTruth: SourceOfTruth<Key, Local, Output>,
memoryCache: Cache<Key, Output>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mobilenativefoundation.store.store5

import kotlinx.coroutines.flow.Flow
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi

interface Write<Key : Any, Output : Any> {
@ExperimentalStoreApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.mobilenativefoundation.store.store5.Bookkeeper
import org.mobilenativefoundation.store.store5.Clear
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.MutableStore
import org.mobilenativefoundation.store.store5.StoreReadRequest
import org.mobilenativefoundation.store.store5.StoreReadResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import kotlinx.coroutines.flow.transform
import org.mobilenativefoundation.store.cache5.Cache
import org.mobilenativefoundation.store.store5.CacheType
import org.mobilenativefoundation.store.store5.Converter
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.Fetcher
import org.mobilenativefoundation.store.store5.SourceOfTruth
import org.mobilenativefoundation.store.store5.Store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fun <Key : Any, Network : Any, Output : Any> storeBuilderFromFetcherSourceOfTrut
): StoreBuilder<Key, Output> =
RealStoreBuilder<Key, Network, Output, Network>(fetcher, sourceOfTruth, memoryCache)

fun <Key : Any, Network : Any, Output : Any, Local: Any> storeBuilderFromFetcherSourceOfTruthMemoryCacheAndConverter(
fun <Key : Any, Network : Any, Output : Any, Local : Any> storeBuilderFromFetcherSourceOfTruthMemoryCacheAndConverter(
fetcher: Fetcher<Key, Network>,
sourceOfTruth: SourceOfTruth<Key, Local, Output>,
memoryCache: Cache<Key, Output>?,
Expand Down Expand Up @@ -76,7 +76,7 @@ internal class RealStoreBuilder<Key : Any, Network : Any, Output : Any, Local :
scope = scope ?: GlobalScope,
sourceOfTruth = sourceOfTruth,
fetcher = fetcher,
converter = converter?: defaultConverter(),
converter = converter ?: defaultConverter(),
validator = validator,
memCache = memoryCache ?: cachePolicy?.let {
CacheBuilder<Key, Output>().apply {
Expand Down Expand Up @@ -134,7 +134,7 @@ internal class RealStoreBuilder<Key : Any, Network : Any, Output : Any, Local :
}
}

private fun <Network: Any, Local: Any, Output: Any> defaultConverter() = object : Converter<Network, Local, Output> {
private fun <Network : Any, Local : Any, Output : Any> defaultConverter() = object : Converter<Network, Local, Output> {
override fun fromOutputToLocal(output: Output): Local =
throw IllegalStateException("non mutable store never call this function")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.mobilenativefoundation.store.store5.impl.extensions
import kotlinx.coroutines.flow.filterNot
import kotlinx.coroutines.flow.first
import org.mobilenativefoundation.store.store5.Bookkeeper
import org.mobilenativefoundation.store.store5.ExperimentalStoreApi
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.MutableStore
import org.mobilenativefoundation.store.store5.Store
import org.mobilenativefoundation.store.store5.StoreReadRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runTest
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.util.InMemoryPersister
import org.mobilenativefoundation.store.store5.util.asSourceOfTruth
import org.mobilenativefoundation.store.store5.util.getData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ class FetcherResponseTests {
)
}


private fun <Key : Any, Output : Any> StoreBuilder<Key, Output>.buildWithTestScope() =
scope(testScope).build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlinx.coroutines.flow.last
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
import org.mobilenativefoundation.store.core5.ExperimentalStoreApi
import org.mobilenativefoundation.store.store5.impl.extensions.inHours
import org.mobilenativefoundation.store.store5.util.assertEmitsExactly
import org.mobilenativefoundation.store.store5.util.fake.Notes
Expand Down

0 comments on commit cf9d9b1

Please sign in to comment.