New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UISwitch.on does not produce element #690

Closed
NicolasRiviere opened this Issue May 19, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@NicolasRiviere
Copy link

NicolasRiviere commented May 19, 2016

Hello !

When i click on my switch, the next element (bool) is produced and visible in my debugger output.
But if i set programmatically the state of my switch, no element is produced and nothing is logged.

mySwitch.rx_value.subscribeNext { (next) in
            print(next)
        }.addDisposableTo(disposeBag)

mySwitch.on = true //Nothing visible in my debugger

The next element "true" should be emitted, no ? Am i missing something ?

Thank you for your help !
Nicolas

@tarunon

This comment has been minimized.

Copy link
Contributor

tarunon commented May 20, 2016

Hi @NicolasRiviere ,
ControlProperty would not observe programatic changes.
You could bind with Variable and change value using Variable.

let switchValue = Variable(false)
(mySwitch.rx_value <-> switchValue)
  .addDisposableTo(disposeBag)
switchValue.asObservable()
  .subscribeNext { (next) in
    print(next)
  }
  .addDisposableTo(disposeBag)

switchValue.value = true 

Please refer to these discussions, I think these would useful for you. (#551, #471)

@NicolasRiviere

This comment has been minimized.

Copy link
Author

NicolasRiviere commented May 20, 2016

Thank you very much for your help @tarunon !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment