-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matt Ramotar <[email protected]>
- Loading branch information
1 parent
1cdb85a
commit e834425
Showing
32 changed files
with
890 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
plugins { | ||
id("storex.android.library") | ||
id("storex.multiplatform") | ||
id("storex.compose") | ||
} | ||
|
||
kotlin { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...x/paging/persistence/PersistenceResult.kt → ...ging/persistence/api/PersistenceResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...n/kotlin/org/mobilenativefoundation/storex/paging/persistence/impl/RealDataPersistence.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.mobilenativefoundation.storex.paging.persistence.impl | ||
|
||
import org.mobilenativefoundation.storex.paging.persistence.api.DataPersistence | ||
import org.mobilenativefoundation.storex.paging.persistence.api.ItemPersistence | ||
import org.mobilenativefoundation.storex.paging.persistence.api.PagePersistence | ||
import org.mobilenativefoundation.storex.paging.runtime.Identifiable | ||
import org.mobilenativefoundation.storex.paging.runtime.Identifier | ||
|
||
class RealDataPersistence<Id : Identifier<Id>, K : Comparable<K>, V : Identifiable<Id>>( | ||
override val items: ItemPersistence<Id, K, V>, | ||
override val pages: PagePersistence<Id, K, V> | ||
) : DataPersistence<Id, K, V> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
.../commonMain/kotlin/org/mobilenativefoundation/storex/paging/runtime/PlaceholderFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.mobilenativefoundation.storex.paging.runtime | ||
|
||
interface PlaceholderFactory<Id : Identifier<Id>,K: Comparable<K>, V : Identifiable<Id>> { | ||
fun create(index: Int, params: PagingSource.LoadParams<K>): V | ||
} |
62 changes: 62 additions & 0 deletions
62
...g/mobilenativefoundation/storex/paging/runtime/internal/pager/api/LinkedHashMapManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.mobilenativefoundation.storex.paging.runtime.internal.pager.api | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.mobilenativefoundation.storex.paging.persistence.api.PersistenceResult | ||
import org.mobilenativefoundation.storex.paging.runtime.Identifiable | ||
import org.mobilenativefoundation.storex.paging.runtime.Identifier | ||
import org.mobilenativefoundation.storex.paging.runtime.PagingSource | ||
|
||
internal interface LinkedHashMapManager<Id : Identifier<Id>, K : Comparable<K>, V : Identifiable<Id>> { | ||
suspend fun isInFlight(key: K): Boolean | ||
|
||
suspend fun isCached(key: K): Boolean | ||
|
||
suspend fun isInDatabase(params: PagingSource.LoadParams<K>): Boolean | ||
|
||
|
||
suspend fun appendPlaceholders(params: PagingSource.LoadParams<K>) | ||
suspend fun prependPlaceholders(params: PagingSource.LoadParams<K>) | ||
|
||
suspend fun getItem(id: Id): V? | ||
|
||
suspend fun getCachedItem(id: Id): V? | ||
suspend fun getPersistedItem(id: Id): V? | ||
|
||
suspend fun getCachedPage(key: K): PagingSource. LoadResult. Data<Id, K, V>? | ||
suspend fun getPersistedPage(key: K): PagingSource. LoadResult. Data<Id, K, V>? | ||
|
||
suspend fun saveItem(item: V) : PersistenceResult<Unit> | ||
suspend fun getItemsInOrder(): List<V?> | ||
|
||
suspend fun putPageNode(key: K, pageNode: PageNode<K>) | ||
|
||
suspend fun appendPage( | ||
params: PagingSource.LoadParams<K>, | ||
loadResult: PagingSource.LoadResult.Data<Id, K, V> | ||
) | ||
|
||
suspend fun prependPage( | ||
params: PagingSource.LoadParams<K>, | ||
loadResult: PagingSource.LoadResult.Data<Id, K, V> | ||
) | ||
|
||
suspend fun removeItem(id: Id): PersistenceResult<Unit> | ||
suspend fun removeAllItems(): PersistenceResult<Unit> | ||
|
||
suspend fun removePage(key: K) | ||
suspend fun removeAllPages(): PersistenceResult<Unit> | ||
|
||
suspend fun invalidate() | ||
|
||
suspend fun queryItems(predicate: (V) -> Boolean): PersistenceResult<List<V>> | ||
|
||
fun observeItem(id: Id): Flow<V?> | ||
|
||
data class PageNode<K : Any>( | ||
val key: K, | ||
var isPlaceholder: Boolean = false, | ||
var isInFlight: Boolean = false, | ||
var prev: PageNode<K>? = null, | ||
var next: PageNode<K>? = null | ||
) | ||
} |
Oops, something went wrong.