ListMonitor refetch does not allow "Fetch Chain builders" #202

Closed
opened 2025-12-29 15:26:34 +01:00 by adam · 3 comments
Owner

Originally created by @demonar on GitHub (Apr 2, 2018).

i'm updating the implementation on a project and found that when trying to update the old fashioned where, order, tweak clauses to the new form, i'm not allowed, but on the monitorList method i still can, this leaves a mix of styles in the code, if i were to parametrize some of the clauses to recall them i couldn't as they're not compatible, is there a way to add this in the future?

Originally created by @demonar on GitHub (Apr 2, 2018). i'm updating the implementation on a project and found that when trying to update the old fashioned where, order, tweak clauses to the new form, i'm not allowed, but on the monitorList method i still can, this leaves a mix of styles in the code, if i were to parametrize some of the clauses to recall them i couldn't as they're not compatible, is there a way to add this in the future?
adam added the wontfix label 2025-12-29 15:26:34 +01:00
adam closed this issue 2025-12-29 15:26:35 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Apr 14, 2018):

@demonar Hi, can you give more information on what you tried that didn't work?

@JohnEstropia commented on GitHub (Apr 14, 2018): @demonar Hi, can you give more information on what you tried that didn't work?
Author
Owner

@demonar commented on GitHub (Apr 15, 2018):

lets say i have this monitor:

typealias ListEntityType = SomeEntity
let monitor = appStack.dataStack.monitorList(
From<ListEntityType>()
.where(\.someProperty == false &&
\.someOtherProperty == true &&
\.someMoreProperty == myValue ?? "")
.orderBy(.descending(\.created), .descending(\.elementId))
.tweak { $0.fetchBatchSize = 20 })

and after an update i need to refetch:

self.monitor.refetch(Where<ListEntityType>("someProperty", isEqualTo: false) &&
Where<ListEntityType>("someOtherProperty", isEqualTo: true) &&
Where<ListEntityType>("someMoreProperty", isEqualTo: otherElement.name),
OrderBy<ListEntityType>(.descending("created"), .descending("elementId")),
Tweak { $0.fetchBatchSize = 20 })

as you can see i need to do it the old fashioned way as the refetch method does not allow the chain builder

@demonar commented on GitHub (Apr 15, 2018): lets say i have this monitor: ` typealias ListEntityType = SomeEntity` ` let monitor = appStack.dataStack.monitorList(` ` From<ListEntityType>()` ` .where(\.someProperty == false &&` ` \.someOtherProperty == true &&` ` \.someMoreProperty == myValue ?? "")` ` .orderBy(.descending(\.created), .descending(\.elementId))` ` .tweak { $0.fetchBatchSize = 20 })` and after an update i need to refetch: ` self.monitor.refetch(Where<ListEntityType>("someProperty", isEqualTo: false) &&` ` Where<ListEntityType>("someOtherProperty", isEqualTo: true) &&` ` Where<ListEntityType>("someMoreProperty", isEqualTo: otherElement.name),` ` OrderBy<ListEntityType>(.descending("created"), .descending("elementId")),` ` Tweak { $0.fetchBatchSize = 20 })` as you can see i need to do it the old fashioned way as the refetch method does not allow the chain builder
Author
Owner

@JohnEstropia commented on GitHub (Dec 5, 2018):

It's been many months and I apologize that this issue got buried. Looking back into refetch(), it's not really compatible with fetch builders because of it's special nature:

  1. It replaces only the FetchClause that you specify, which means it keeps the old clauses for those you didn't specify
  2. It only accepts Where, OrderBy, and Tweak clauses.

Due to these the current refetch() API being "old fashioned" is by design.

@JohnEstropia commented on GitHub (Dec 5, 2018): It's been many months and I apologize that this issue got buried. Looking back into `refetch()`, it's not really compatible with fetch builders because of it's special nature: 1. It replaces only the `FetchClause` that you specify, which means it keeps the old clauses for those you didn't specify 2. It only accepts `Where`, `OrderBy`, and `Tweak` clauses. Due to these the current `refetch()` API being "old fashioned" is by design.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#202