Paging#630
Closed
matt-ramotar wants to merge 18 commits into
Closed
Conversation
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
* Define PagingBuffer Signed-off-by: mramotar <mramotar@dropbox.com> * Define MutablePagingBuffer Signed-off-by: mramotar <mramotar@dropbox.com> --------- Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
* Implement RealDispatcher and Related Classes Signed-off-by: mramotar <mramotar@dropbox.com> * Implement RealOptionalInjector Signed-off-by: mramotar <mramotar@dropbox.com> * Implement DefaultLogger Signed-off-by: mramotar <mramotar@dropbox.com> --------- Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
#627) Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
Signed-off-by: mramotar <mramotar@dropbox.com>
| dependencies { | ||
| implementation(libs.kotlin.stdlib) | ||
| implementation(project(":store")) | ||
| implementation(project(":cache")) |
Contributor
There was a problem hiding this comment.
is cache not needed anymore?
|
|
||
| android { | ||
| namespace = "org.mobilenativefoundation.store.paging5" | ||
| namespace = "org.mobilenativefoundation.paging.core" |
Contributor
There was a problem hiding this comment.
you can also do org.mobilenativefoundation.store5.paging.core
in case you want to ever have something like 5/6 at same time
| * @param P The type of the parameters associated with each page of data. | ||
| * @param D The type of the data items. | ||
| */ | ||
| interface AggregatingStrategy<Id : Comparable<Id>, K : Any, P : Any, D : Any> { |
Contributor
There was a problem hiding this comment.
I still prefer Key,Request,Response as the param names :-)
|
Any updates on this? |
Collaborator
Author
|
@OliverRhyme sorry to be slow. Update here: #671 (comment) |
Member
|
A few high level comments:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context:
launchPagingStoreDoes Not Reflect Latest Writes in Mutable Store #602Description
Introducing a solution for paging in KMP projects. Motivations:
Type of Change
Test Plan
Unit tests
Checklist:
Before submitting your PR, please review and check all of the following:
Additional Notes:
Paging Technical Design Doc
1. Overview
Modular and flexible architecture. Using builder, reducer, middleware, and post-reducer effect patterns. Unidirectional
data flow. The
Pageris the main component. Actions are dispatched through thePager. ThePagerBuildercreatesthe
Pager. It allows configuration of the paging behavior. ThePagingSourcedefines the data loading logic. TheFetchingStrategydetermines when to fetch the next page. TheAggregatingStrategycombines loaded pages into a single list. TheReducerhandles state changes based on actions. When an action is dispatched, it goes through the middleware pipeline. The middleware can modify the action. The reducer then updates the state based on the action. After the reducer, we invoke post-reducer effects associated with the action and new state. The updated state is sent back thePagerand emitted to the UI.2. Key Components
Pager: The main entry point for the paging library. It coordinates the paging process and provides access to the paging state and data.PagingState: Represents the current state of the paging data, including loaded pages, errors, and loading status.PagingAction: Defines the actions that can be dispatched to modify the paging state.Reducer: Responsible for taking the current paging state and a dispatched action, and producing a new paging state based on the action and the current state.Middleware: Intercepts and modifies paging actions before they reach the reducer, allowing for pre-processing, logging, or any other custom logic.Effect: Represents side effects or additional actions that need to be performed after the state has been reduced based on a dispatched action.PagingSource: Represents a data source that provides paged data, emitting a stream of load results.PagingBuffer: A custom data structure for efficiently storing and retrieving paging data.3. Customizations
Providing many extension points and customization options to tailor behavior. Main customization points:
PagingConfig: Allows configuring the paging behavior, such as page size, prefetch distance, and insertion strategy.FetchingStrategy: Determines whether to fetch more data based on the current state of the pager.AggregatingStrategy: Defines how loaded pages of data should be combined and ordered to form a coherent list of paging items.ErrorHandlingStrategy: Specifies different strategies for handling errors during the paging process.UserCustomActionReducer: Allows defining custom reducers for handling user-defined actions.4. Data Flow
Unidirectional data flow. Main steps:
Pageris configured usingPagerBuilderand provided an initial key, flow of anchor position, and paging config.Pagersubscribes to thePagingSourceto receive paging data updates.PagingActionis dispatched, it goes through the configuredMiddlewarechain. This enables interception and modification of the action.Reducer, which reduces the currentPagingStatebased on the action and returns a newPagingState.Effectinstances are launched, enabling side effects to be performed based on the newPagingState.PagerupdatesStateManagerwith the newPagingState.FetchingStrategydetermines when to fetch the next page of data based on thePagingConfigand currentPagingState.QueueManagerenqueues the page key, and theJobCoordinatorcoordinates the execution of the paging job.PagingSourceloads the requested page and emits the loaded data through thePagingSourceStreamProvider.MutablePagingBufferfor efficient retrieval and aggregation.AggregatingStrategyaggregates the loaded pages into a single list, which is then emitted through thePagerfor consumption by the UI.5. Sample Code
See https://github.com/MobileNativeFoundation/Store/tree/paging/paging