Hi,
I am exploring the new flexible sync feature and I have an issue regarding updating data after adding a subscription query.
I have this PersonTableView
struct PersonsTableView: View {
@Environment(\.realm) var realm
@ObservedResults(Person.self, sortDescriptor: SortDescriptor(keyPath: \Person.name)) var persons
@State private var selection: Person? = nil
var body: some View {
Table(persons, selection: $selection) {
...
}
.onAppear(perform: setPersonsQuerySubscription)
}
private func setPersonsQuerySubscription() {
let subscriptions = realm.subscriptions
subscriptions.write {
let query = QuerySubscription(name: "personsList") { $0._partitionKey == "userID" }
subscriptions.append(query)
}
}
}
When the view appears, the query subscription is created but persons is empty. I have to navigate away and back to this view for the persons to appear inside the table.
I believe .onAppear returns before realm downloads new data but, shouldn’t @ObserevedResults update the table as soon as it has new results?
Or it could be a macOS Table related issue?
Thank you!