-
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.
Merge pull request #8 from matt-ramotar/core
Simplify the core API
- Loading branch information
Showing
6 changed files
with
72 additions
and
92 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
39 changes: 39 additions & 0 deletions
39
...g-runtime/src/commonMain/kotlin/org/mobilenativefoundation/storex/paging/runtime/Pager.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 |
---|---|---|
@@ -1,7 +1,46 @@ | ||
package org.mobilenativefoundation.storex.paging.runtime | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.flow.StateFlow | ||
import org.mobilenativefoundation.store.store5.Updater | ||
import org.mobilenativefoundation.storex.paging.custom.FetchingStrategy | ||
import org.mobilenativefoundation.storex.paging.custom.LaunchEffect | ||
import org.mobilenativefoundation.storex.paging.custom.Middleware | ||
import org.mobilenativefoundation.storex.paging.custom.SideEffect | ||
import org.mobilenativefoundation.storex.paging.persistence.api.ItemPersistence | ||
import org.mobilenativefoundation.storex.paging.persistence.api.PagePersistence | ||
import org.mobilenativefoundation.storex.paging.runtime.internal.pagingScope.impl.PagerBuilder | ||
|
||
interface Pager<ItemId : Any, PageRequestKey : Any, ItemValue : Any> { | ||
val state: StateFlow<PagingState<ItemId, PageRequestKey, ItemValue>> | ||
suspend fun dispatch(action: Action<ItemId, PageRequestKey, ItemValue>) | ||
suspend fun getUpdatingItem(id: ItemId): UpdatingItem<ItemId, ItemValue> | ||
|
||
interface Builder<ItemId : Any, PageRequestKey : Any, ItemValue : Any> { | ||
fun setInitialState(state: PagingState<ItemId, PageRequestKey, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setInitialLoadParams(params: PagingSource.LoadParams<PageRequestKey>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setPagingSource(source: PagingSource<ItemId, PageRequestKey, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setCoroutineDispatcher(dispatcher: CoroutineDispatcher): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun addLaunchEffect(effect: LaunchEffect): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun addSideEffect(effect: SideEffect<ItemId, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun addMiddleware(mw: Middleware<PageRequestKey>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setInitialFetchingState(state: FetchingState<ItemId, PageRequestKey>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setFetchingStrategy(strategy: FetchingStrategy<ItemId, PageRequestKey, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setErrorHandlingStrategy(strategy: ErrorHandlingStrategy): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setItemMemoryCache(cache: MutableMap<ItemId, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setPageMemoryCache(cache: MutableMap<PageRequestKey, PagingSource.LoadResult.Data<ItemId, PageRequestKey, ItemValue>>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setItemPersistence(persistence: ItemPersistence<ItemId, PageRequestKey, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setPagePersistence(persistence: PagePersistence<ItemId, PageRequestKey, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setItemUpdater(updater: Updater<ItemId, ItemValue, *>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setPlaceholderFactory(placeholderFactory: PlaceholderFactory<ItemId, PageRequestKey, ItemValue>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun setInitialOperations(operations: List<Operation<ItemId, PageRequestKey, ItemValue>>): Builder<ItemId, PageRequestKey, ItemValue> | ||
fun build(): Pager<ItemId, PageRequestKey, ItemValue> | ||
} | ||
|
||
companion object { | ||
fun <Id : Any, K : Any, V : Any> builder( | ||
pagingConfig: PagingConfig<Id, K> | ||
): Builder<Id, K, V> = PagerBuilder(pagingConfig) | ||
} | ||
|
||
} |
44 changes: 0 additions & 44 deletions
44
...ime/src/commonMain/kotlin/org/mobilenativefoundation/storex/paging/runtime/PagingScope.kt
This file was deleted.
Oops, something went wrong.
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
25 changes: 0 additions & 25 deletions
25
...mobilenativefoundation/storex/paging/runtime/internal/pagingScope/impl/RealPagingScope.kt
This file was deleted.
Oops, something went wrong.