Let say we have array of InvoiceDataModel
private let invoices Variable<[InvoiceDataModel]> = Variable([])
class InvoiceDataModel {
let id: Variable<Int>
var entity: Variable<InvoiceDto>
var isSelected: Variable<Bool>
}
On tap on checkbox I am changing value of isSelected. What I want to achieve is to react on isSelect change to:
- calculate total amount of selected items (each entity has
var amount: Double
) - detect if all items in collection are selected
Is it possible to observe whole array and react on single property from element change? Not sure how am I supposed to achieve this.
Probably my approach to this case is totally wrong. However I am not sure how am I supposed to operate here in a different way.