How can I get notified when data has changed to process it? I have a simple code for easy to understand what I want:
class Data {
var data: [Int] = [] {
didSet {
print("changed")
}
}
}
class Process {
var data: Data
init(data: Data) {
self.data = data
}
func processIfChanged() {
//how to run this code?
}
}
class Global {
var data: [Data] = []
var process: [Process] = []
}
let global = Global()
global.data = [Data()]
global.process = [Process(data: global.data.first!)]
global.data.first!.data.append(1)
global.data.first!.data.append(5)
Can try this using Combine module