# Common RxSwift Problems and Their Solutions

DevFeed: [Common RxSwift Problems and Their Solutions](<https://devfeed.tech/articles/half-baked-solutions-to-common-rxswift-problems-22303.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/Half-Baked-Solutions-To-Common-RxSwift-Problems/>)

Author: Keegan Rush

Published: 2017-05-23T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [iOS](<https://devfeed.tech/topics/ios.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [ui](<https://devfeed.tech/topics/ui.md>)

Tags: [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [ios](<https://devfeed.tech/tags/ios.md>), [merge](<https://devfeed.tech/tags/merge.md>), [module](<https://devfeed.tech/tags/module.md>), [programming](<https://devfeed.tech/tags/programming.md>), [property](<https://devfeed.tech/tags/property.md>), [swift](<https://devfeed.tech/tags/swift.md>), [ui](<https://devfeed.tech/tags/ui.md>), [validation](<https://devfeed.tech/tags/validation.md>)

## AI overview

A tutorial describing solutions to several RxSwift challenges in iOS development, including UIKit interaction through RxCocoa, merging multiple observables, and conditionally triggering an observable based on validation.

## Source excerpt

I've been using RxSwift in some of my latest iOS projects. While I feel that it's provided elegant UI binding and a natural feel to asynchronous programming, I have to admit that it came with numerous growing pains. I struggled to find documented solutions to some of the challenges I was facing, as RxSwift is not as widely adopted as its more affluent Java and .Net counterparts. Here are some of those hurdles that I faced, along with my solutions. Why can't I access the tap method of my UIButton? One of the greatest benefits of Rx is its UI binding capabilities. So you must imagine how peeved off I was when I couldn't do something as simple as bind some logic to taps on a UIButton. Luckily, the solution is just as simple as the problem. import UIKit import RxSwift import RxCocoa let button = UIButton() button.rx.tap.bind { print("That wasn't too hard, was it?") } See that sneaky import RxCocoa at the top there? RxSwift functionality relating to UIKit is found in the RxCocoa module. The rx property on UIButton that I'm using in the snippet comes from RxCocoa. You can find it on most UIKit objects. It's what powers RxSwift's interaction with UIButton, UITableView, UIImageView, and all of the other usual suspects. You can find an RxSwift extension on most UIKit objects - just look out for the object plus Rx.swift - e.g. UITableView+Rx.swift. How do I combine the output from multiple observables into one? If you have data from multiple sources, and want to treat them as one, you need to merge them. let cars = Observable.from(["Nissan", "Ford", "BMW"]) let tanks = Observable.from(["Tiger II", "T-44", "Panther"]) let bikes = Observable.from(["Ducati", "Honda", "Kawasaki"]) let landVehicles = Observable.of(cars, tanks, bikes).merge() landVehicles.subscribe(onNext: { print($0) }) /* Output: Nissan Ford Tiger II BMW T-44 Ducati Panther Honda Kawasaki */ First, we combine the three observables using of. You can use the of operator on any list of items to create an Observable