fetchLimit is not working with ListPublisher #296

Closed
opened 2025-12-29 18:25:24 +01:00 by adam · 3 comments
Owner

Originally created by @EricSKCheng on GitHub (Nov 13, 2019).

First I create a ListPublisher

CoreStoreDefaults.dataStack.publishList(From<Article>()
            .orderBy(.descending(\.publishDate))
            .tweak { $0.fetchLimit = 10 })

and add a addObserver

addObserver(self) { [weak self] (listPublisher) in
            
        }

however if I add a new article to the corestore, the observer will return more than 10 items.

Originally created by @EricSKCheng on GitHub (Nov 13, 2019). First I create a ListPublisher ``` CoreStoreDefaults.dataStack.publishList(From<Article>() .orderBy(.descending(\.publishDate)) .tweak { $0.fetchLimit = 10 }) ``` and add a addObserver ``` addObserver(self) { [weak self] (listPublisher) in } ``` however if I add a new article to the corestore, the observer will return more than 10 items.
adam closed this issue 2025-12-29 18:25:24 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Nov 13, 2019):

This is a limitation of NSFetchedResultsController which also affects ListMonitor.

Fortunately, ListPublishers use diffing instead of relying on FRC update methods, so we can easily simulate the fetch limit by hand.(i.e. just truncate the unwanted items from the snapshot)

I'll post an update soon.

@JohnEstropia commented on GitHub (Nov 13, 2019): This is a limitation of `NSFetchedResultsController` which also affects `ListMonitor`. Fortunately, `ListPublisher`s use diffing instead of relying on FRC update methods, so we can easily simulate the fetch limit by hand.(i.e. just truncate the unwanted items from the snapshot) I'll post an update soon.
Author
Owner

@EricSKCheng commented on GitHub (Nov 13, 2019):

Thx.

@EricSKCheng commented on GitHub (Nov 13, 2019): Thx.
Author
Owner

@JohnEstropia commented on GitHub (Nov 14, 2019):

Implemented in develop branch 👍

@JohnEstropia commented on GitHub (Nov 14, 2019): Implemented in `develop` branch 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#296