Integrating RxSwift Into Your Brain and Code Base: Part 2

Consolidating the ProgressObserver

Simplifying the ProgressView

Simplifying the SettingsViewController

let inputValues = Observable.combineLatest(displayNameTextField.rx.text.orEmpty, serviceTypeTextField.rx.text.orEmpty) { (displayName: $0, serviceType: $1) }doneButton.rx.tap
.bind(onNext: { [weak self] displayName, serviceType in
isValid(displayName: displayName, serviceType: serviceType) {
self?._didCreateChatRoom.onNext((displayName, serviceType: serviceType))
else {
let alert = UIAlertController(title: "Error", message: "You must set a valid room name and your display name", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
self?.present(alert, animated: true, completion: nil)
.disposed(by: disposeBag)

Simplifying the SessionContainer `received` Observable

Simplifying the SessionContainer `didFinishReceivingResource` Closure

Consolidating the MainViewController’s `sendMessageButton` Output

Separating the text clearing behavior

Simplifying and Correcting the Send Text Feature

Inlining All the Things!

Removing Nested Subscribes: `browseForPeers`

Extracting the UIAlertController Presentation

Extracting the UIImagePickerController Presentation

Un-nesting `didFinishPickingMediaWithInfo`

Taking Advantage of RxSwift Async Abilities

Epilogue: What’s Left?



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store