How do I make a @FetchAll
-like auto-updating property that depends on an input value?
#73
-
This feels like a very naive question, but I can't see what the equivalent of public struct TaxonView: View {
let focused: [Taxon.ID]
@FetchAll(Taxon.all.where { focused.contains($0) }) var taxa // Cannot use instance member 'focused' within property initializer; property initializers run before 'self' is available
var body: some View { Text("todo") }
} I understand the error, but I don't understand what I should do to get the equivalent effect (in particular, that |
Beta Was this translation helpful? Give feedback.
Answered by
stephencelis
Jun 2, 2025
Replies: 1 comment
-
You can do so in a custom initializer. Here's an example from the Reminders demo: This is similar to how Apple constructs dynamic queries for SwiftData. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tikitu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do so in a custom initializer. Here's an example from the Reminders demo:
https://github.com/pointfreeco/sharing-grdb/blob/27aa92082156aaaecd002620ff200723eaf3f239/Examples/Reminders/RemindersDetail.swift#L24
This is similar to how Apple constructs dynamic queries for SwiftData.