antoninbiret / RxEureka

This library is a small RxSwift wrapper around Eureka
MIT License
37 stars 9 forks source link

How can I bindto: StepperRow #22

Closed sedwo closed 6 years ago

sedwo commented 6 years ago

I'm trying the following:

// Bind viewModel Variable to --> row UI
self.viewModel.quantityRxString
    .asObservable()
    .bind(to: quantityRow?.cell.stepper.rx.value)
    .disposed(by: self.disposeBag)

But it fails with: image

sedwo commented 6 years ago

@antoninbiret Yet this work fine:

        // Bind row UI to viewModel Variable
        self.quantityRow?.cell.stepper.rx.value
            .asObservable()
            .bind(to: self.viewModel.quantityRxDouble)
            .disposed(by: self.disposeBag)

note: changed quantityRxString to quantityRxDouble

sedwo commented 6 years ago

Solved!

let quantityRxDouble = Variable<Double?>(0.0)

// Bind viewModel Variable to --> row UI
self.viewModel.quantityRxDouble
    .asObservable()
    .bind(to: self.quantityRow!.rx.value)
    .disposed(by: self.disposeBag)

// Bind row UI to viewModel Variable
self.quantityRow!.rx.value
    .asObservable()
    .bind(to: self.viewModel.quantityRxDouble)
    .disposed(by: self.disposeBag)