Reputation: 26004
I am having trouble finding my way around in RxSwift. Like now I need to update a UILabel When a UIButton is pressed. My take on this is:
But I can not find any documentation for RxSwift 3.0 or newer?
Upvotes: 1
Views: 2469
Reputation: 9402
RxSwift, in your case, lets you manipulate events from an Observable of one type, into a different type.
In this case you would want to do something like this:
btnButton.rx.tap // This is a ControlEvent<Void> (you can think of it as Observable<Void> for our purposes
.map { return "Button was Pressed" } // This is now Observable<String>
.asDriver(onErrorJustReturn: "") // This is now Driver<String>
.drive(lblText.rx.text)
.disposed(by: disposeBag)
Lets go through this step by step
tap
ObservableTL;DR this would set the label every time you tap the button, which won't help much since it changes to the same String, but you can apply that technique to map dynamic strings etc.
Good luck on the great journey with RxSwift, and feel free to join the Slack channel, since there's mach more help and ongoing activity there
Upvotes: 3