I have prepared workaround by getting values from list monitor but not sure if it's correct. I would like to call fetchAll after listMonitorDidChange actually when core data records are updated.
func listMonitorDidChange(_ monitor: ListMonitor<ExerciseEntity>) {
var exerciseFromMonitor = [ExerciseEntity]()
for index in (0...monitor.numberOfObjects() - 1) {
exerciseFromMonitor.append(monitor[index])
}
print(exerciseFromMonitor)
if exerciseFromMonitor.count > 0 {
//updateData(with: routinesFromMonitor)
}
}
Originally created by @matrosovDev on GitHub (Aug 13, 2019).
Can you please comment on this [question](https://stackoverflow.com/questions/57429039/corestore-how-to-observe-changes-in-database)
I have prepared workaround by getting values from list monitor but not sure if it's correct. I would like to call fetchAll after listMonitorDidChange actually when core data records are updated.
```
func listMonitorDidChange(_ monitor: ListMonitor<ExerciseEntity>) {
var exerciseFromMonitor = [ExerciseEntity]()
for index in (0...monitor.numberOfObjects() - 1) {
exerciseFromMonitor.append(monitor[index])
}
print(exerciseFromMonitor)
if exerciseFromMonitor.count > 0 {
//updateData(with: routinesFromMonitor)
}
}
```
adam
added the question label 2025-12-29 15:28:11 +01:00
Looks I figure out, how it works, so evertyime data is changed in CoreData list motor is notified about it and already exist with needed data in it, as I understood we just need this callback function to reload data for example and etc.
My question is can I search through monitor. So I need to search or filter this:
let monitor = CoreStore.monitorSectionedList(
From<ListEntityType>()
.sectionBy(#keyPath(ListEntityType.muscle.name)) { (sectionName) -> String? in
"\(String(describing: sectionName)) years old"
}
.orderBy(.ascending(\.name))
)
do I need to reassign let monitor property each time when I search?
let's say textfield triggered by entering a latter should I init monitor again with some .where statement?
@matrosovDev commented on GitHub (Aug 15, 2019):
Looks I figure out, how it works, so evertyime data is changed in CoreData list motor is notified about it and already exist with needed data in it, as I understood we just need this callback function to reload data for example and etc.
My question is can I search through monitor. So I need to search or filter this:
```
let monitor = CoreStore.monitorSectionedList(
From<ListEntityType>()
.sectionBy(#keyPath(ListEntityType.muscle.name)) { (sectionName) -> String? in
"\(String(describing: sectionName)) years old"
}
.orderBy(.ascending(\.name))
)
```
do I need to reassign `let monitor` property each time when I search?
let's say textfield triggered by entering a latter should I init `monitor` again with some .where statement?
@matrosovDev ListMonitor would not be your tool for the job here. I would suggest to use a plain fetchAll whenever your textField triggers a new search
@JohnEstropia commented on GitHub (Sep 22, 2019):
@matrosovDev ListMonitor would not be your tool for the job here. I would suggest to use a plain `fetchAll` whenever your textField triggers a new search
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @matrosovDev on GitHub (Aug 13, 2019).
Can you please comment on this question
I have prepared workaround by getting values from list monitor but not sure if it's correct. I would like to call fetchAll after listMonitorDidChange actually when core data records are updated.
@matrosovDev commented on GitHub (Aug 15, 2019):
Looks I figure out, how it works, so evertyime data is changed in CoreData list motor is notified about it and already exist with needed data in it, as I understood we just need this callback function to reload data for example and etc.
My question is can I search through monitor. So I need to search or filter this:
do I need to reassign
let monitorproperty each time when I search?let's say textfield triggered by entering a latter should I init
monitoragain with some .where statement?@JohnEstropia commented on GitHub (Sep 22, 2019):
@matrosovDev ListMonitor would not be your tool for the job here. I would suggest to use a plain
fetchAllwhenever your textField triggers a new search