May 28Dealing With Resources in RxSwiftThe Observable.using(_:observableFactory:) function is designed to tie the lifetime of a resource to the subscription of an Observable. In order to use it, you provide a closure that creates the resource and another closure that returns the Observable that will be tied to the resource. Then anytime the Observable returned…3 min read
Jul 20, 2021Convert a Swift Delegate to RxSwift ObservablesMost of the delegate protocols in the UIKit library already have reactive methods designed to convert the delegate into Observables. …Rxswift4 min read
Nov 3, 2019VIPER, RxSwift-ifiedI have committed a new repository as an example of using Rx to implement the VIPER architecture. …I OS7 min read
Sep 19, 2019An Aside: Before Code is WrittenMost of my articles have been very code heavy but for this one I want to take time to discuss a bit about the process of developing a program, with the goal of documenting some of the non-code processes involved in creating an application. …Agile4 min read
Apr 13, 2019Integrating RxSwift Into Your Brain and Code Base: Part 2In part 1 of this series we took one of Apple’s sample apps and added RxSwift to it. In doing so, we replaced all the IBActions, Delegates, Notifications, and KVO calls with their RxSwift counterparts. However, we didn’t really change the semantics of the code, it’s still just as imperative…Swift10 min read
Mar 24, 2019Integrating RxSwift Into Your Brain and Code BaseSo you have recently learned about RxSwift and RxCocoa. You have read some tutorials and maybe even a book or two. You have a program already in existence or maybe you are starting a new app but you can’t afford to do too much experimentation. …Swift7 min read
Feb 3, 2019RxSwift’s Many Faces of FlatMapWith most types that have a flatMap method (for example Array and Optional) there is no time element involved and thus there is only one way to flatten them, but RxSwift’s Observable type has a time element which gives us more possibilities on how to flatten a group of them…Rxswift3 min read
Jan 20, 2019RxSwift and Handling Invalid TokensI was recently asked to help with creating a system that would reauthorize a user when a 401 was encountered during a network request. After reauthorizing the user, it should retry the request with the new token. …Rxswift5 min read
Oct 28, 2018Recipes for Combining Observables in RxSwiftSeveral operators exist to combine multiple observables into one. This document shows the basics of the various combining operators and shows some more advanced recipes using them. Combine Latest The combineLatest operator is used whenever you have two or more observables emitting values, and you want access to the latest value emitted…Rxswift4 min read
Apr 13, 2017Encapsulating the User in a FunctionBelow is code that many of us have written. Some of us might have an example of this code in more than one place in an app. There is probably even an Apple example that looks very much like it. This code might be found in a profile edit…Swift4 min read