A code lab for learning state management with RxSwift
I was inspired by Jake Wharton's talk on "Managing State with RxJava" https://jakewharton.com/the-state-of-managing-state-with-rxjava/. If you haven't watched it, I recommend starting there. Afterward, clone the repo and work through the code lab.
- Checkpoint 1 - Managing state starting point.
- This is the starting point of the code lab:
- We have a simple
CreateAccountViewController
that is presented when the user taps on theCreate Account
button. - Inside the implementation of the
CreateAccountViewController
you will find familiar Rx code that you'd might write. In Jake Wharton's talk, he discusses the so-called bad practices of side effects (aka..do(onNext()
andleaving the monad
) that we typically write when we get started with Rx. - In the talk, he identifies several red lines:
- In the
flatMap
we reach into the UI and get the text out of the twoUITextField
s. - Before and after the network calls, we use a
do(onNext())
to disable/enable thecreateAccountButton
and to show/hide theprocessingView
.
- In the
- Let's see if we can improve this!
- We have a simple
- This is the starting point of the code lab: