RxSwift @ NSMeetup
So you want to be a reactive programming beginner?
As someone formerly in the training business, I’m often thinking about the best way to explain things. Something I really enjoy doing is attending talks from beginners — it’s always interesting to hear something you already know (or think you already know!) explained by someone coming into it with fresh eyes.
I started looking into reactive programming and RxSwift late last year, and now it was my turn to be the noob explaining something at a meetup.
Reactive programming is one more thing in the development toolbox. It’s not necessarily something that takes over an entire project; you can use reactive programming elements in just parts of an application if you want.
What are the big ideas of reactive programming? We can turn to Wikipedia for the answer:
- Data flows
- Propagation of change
Thinking about your app in terms of data — what’s coming in, what’s going out, how do you manage it going from one place to the other — is the core of it for me. Then it’s a matter of pretending you’re a series of tubes, like the Internet, to manage, tranform, and push the data along.
For the talk, I used a simple app where you provide the angles, and it draws triangles.
You can see the code from the demo on GitHub; there’s one folder with the classic Cocoa UIKit version, and one with the RxSwift version coded up during the talk.
Here are the slides:
And finally, if you’re interested in reading more there are a ton of places to look:
- For general theory on Rx: ReactiveX.io
- Why use Rx?
- The official RxSwift Getting Started guide
- There were a lot of questions about dispose bags that I couldn’t answer 😇 — you can read more about them in the Disposing section of the guide
- One of the best Rx blogs with lots of useful code examples: rx_marin
- Finally, right in the RxSwift repository is the RxExample folder. Don’t miss it when you clone the repository locally and start exploring!
I really enjoy the data flow model and declarative nature of Rx, and I hope to continue poking around and learning. Happy reactive programming adventures to you!