Let's say we have a class Dog
class Dog {
let age = BehaviorRelay<Int>(value: 1)
}
and somewhere we have an array property with all the dogs
let dogs = BehaviorRelay<[Dog]>(value: [..., ...])
now I want to create UI which needs array of dogs listed in UITableView, and it wants to be updated (call reloadDate under the hood) when age of each dog changes?
So when I simply subscribe like that:
dogs.subscribe(onNext: {
print("\($0)")
})
the subscription will get fired when new dog comes to array, or some leaves array, but not when dogs mature, i.e.:
dogs.value[1].age.accept(2)
I know about flatMap and flatMapLatest, but they seems to expects Dogs to be a plain type, not array. I'm new to RxSwift, any help will be appreciated!