I have defined:
let currentHours:Variable<Float> = Variable(0.0)
let currentRate:Variable<Float> = Variable(0.0)
and I would like to make an Observable with combineLatest to sum these two value:
Observable.combineLatest(currentHours, currentRate, { (h, r) -> Float in
return Float(h+r)
})
and I also try:
let c = Observable.combineLatest(currentHours, currentRate) { $0 + $1 }
I always get compiler error. thanks
Try this:
let currentHours:Variable<Float> = Variable(0.0)
let currentRate:Variable<Float> = Variable(0.0)
let hoursAndRate = Observable.combineLatest(currentHours.asObservable(), currentRate.asObservable()){
return $0 + $1
}
As you can see the key is in passing currentHours and currentRate as Observables in the function parameters.