Implementing RxSwift vs. Swift Delegate

Maple Ong
4 min readNov 19, 2018

Delegation is a commonly used design pattern that allows an object to hand off work to another object (of perhaps a different type) through a protocol.

On the other hand, reactive programming is oriented around the flow and transfer of data through the spread of change in the application’s ecosystem. This is done through Observers, Observables and Schedulers, where the Observers look out for the emission of Observables on the thread the Schedulers tell them to run on.

James Rochabrun’s article, Implementing delegates in Swift, step by step, is one of the first articles I read on delegates.

.gif credit: James Rochabrun

This is a simple application where using two view controllers, A and B. View Controller A conforms to the delegate protocol of View Controller B, where View Controller B tells A which user-selected colour to show.

I will be using James’s example of delegates to compare to the same implementation using Reactive Programming (RxSwift).

A Quick Recap on Delegates

// 1
override func prepare(for segue…

--

--