Raffling my ticket to NSSpain 2017

This year is the 5th edition of NSSpain - the only international iOS/macOS conference in Spain and one of the best in the world I’ve been to. There are many reasons why I think NSSpain is the right way to do a conference, including but not limited to - single track, remote location, and best-in-business speakers… (And that’s why last year I sponsored a student-ticket to NSSpain.) Speakers receive not only free entry to the full conference and free accomodation, but also tons of love from the organizers.

First update to the RxSwift book with version 1.1

This is a short update about the first update to our RxSwift book. First of all, we’d like to thank all of you who posted to our book errata forum! (and if you haven’t hit the forums yet, check ‘em out - it’s the best place to report typos, bugs, and more: https://forums.raywenderlich.com/c/books/rxswift ). I’ve worked with the raywenderlich.com team on a number of books and I must say the RxSwift book has had, so far, the most enthusiastic feedback - we’ve been drowned in questions, thank you messages, and typo/bugs reports.

combineLatest beyond the basics

In the last couple of weeks I got to talk to few people who were either still struggling to understand what exactly does combineLatest do or didn’t know about a more recent power feature. So here it is … a post about combineLatest! What does the combineLatest operator do? combineLatest is super useful and it was the first thing in RxSwift that really made see how powerful Rx is and showed me what kind of problems can be easily solved with RxSwift.

Two free chapters from the RxSwift book!

Last week we announced our brand new RxSwift book (available now)! The book starts with the very basics in Chapter 1, “Hello, world!” and leads the reader through a plethora of topics all the way to Chapter 23, “MVVM” and Chapter 24, “Building a complete app with RxSwift”. Being so detailed about RxSwift knowledge already sets the book apart as a great learning source, but what is really special is that it’s written by four very active RxSwift community memebers and it’s polished by two more editors.

RxSwift book - available now!

After a long time working on this project, I and my friends and colleagues Florent Pillet, Junior Bontognali, Scott Gardner, Ash Furrow, Chris Belanger, and Ray and Vicki Wenderlich are happy to announce that our new book about development with RxSwift is available now! How it came to be? When I first tried out RxSwift (being excited about it by some of the same people who are my co-authors on the book) I immediately noticed that even though there is plenty of information on the Internet, there isn’t a single structured resource where people can learn systematically.

(dotSwift) Unidirectional data flow with RxSwift and RxRealm

In my talk at dotSwift 2017 I start with generic overview of some of the RxSwift basics and move to three complete code examples. In three posts I post the sample code and comment shortly why I chose to highlight these exact examples. I already posted a write up on the GitHub API search example here: http://rx-marin.com/post/dotswift-search-github-json-api/. The second post in the series, the one about presenting view controllers, is online here: http://rx-marin.com/post/dotswift-rxswift-view-controller/.

(dotSwift) Presenting View Controllers with RxSwift

In my talk at dotSwift 2017 I start with generic overview of some of the RxSwift basics and move to three complete code examples. In three posts I’ll post the sample code and comment shortly why I chose to highlight these exact examples. I already posted a write up on the GitHub API search example here: http://rx-marin.com/post/dotswift-search-github-json-api/. Let’s continue with example number two. Presenting a View Controller from RxSwift RxSwift doesn’t neccessarily force you into one architecture or another, it’s really up to you to chose how are you going to structure your application.

(dotSwift) Search GitHub with RxSwift

In my talk at dotSwift 2017 I start with generic overview of some of the RxSwift basics and move to three complete code examples. In three posts I’ll post the sample code and comment shortly why I chose to highlight these exact examples. Let’s start with number one. Searching for GitHub repositories with RxSwift The first example in the talk is a simple single-screen application that allows the user to enter a repository name (or part of it) and search GitHub for matching results.

A smarter Retry with RxSwiftExt

Sometimes your observable will fail with an error but that would not mean that you need to give up trying. For example saving to a file might fail because the file is locked temporarily but a split second later would be unlocked and ready for your changes. Same goes for web requests - there might be a temporary glitch in connectivity which could make the observable fail. RxSwift offers a special operator called retry, which allows you to try another time the observable subscription upon error.

Testing your RxSwift code, part 2

In part 1 I looked into writing very basic tests with RxSwift and life was good. But then I wanted to do more and moved on to writing asynchronous tests… I contributed the code for RxRealm - the Rx extension for RealmSwift owned by the RxSwiftCommunity. For RxRealm I needed some asynchronous tests because Realm’s collections emit notifications (which RxRealm wraps) when the underlaying data changes. So let’s have a look at some of the unit tests I wrote… Asynchronous tests First of all I needed to look into writing asynchronous tests - luckily this is quite easy.

Testing your RxSwift code, part 1

I sat down recently and learned the basics of writing unit tests for RxSwift. It was way easier than I expected and that’s why I’d like to show few of the tests I got to write. Before I start on the code itself I just want to mention how great contributing to open source is. If I didn’t jump in to helping around on the RxSwift-Ext project I’d probably haven’t looked into writing unit tests with RxSwift yet, but I did - and that’s great.

App state with Realm and RxSwift

Intro This post isn’t that much about operators but how to leverage the awesome technology that Realm is. Long story short - I wanted to submit an app for review and literally just before hitting submit I realized I forgot to implement a favorites filter in one of the view controllers. I would’ve quickly hacked something to send it off but since different controllers took care of the navigation bar and the actual table view showing the data could not hack my way around.

Implementing state with scan in RxSwift

Intro Common misconception is that you cannot have state with Rx. Well you can - and there’s a special operator that helps you to: scan. If you’ve ever used reduce in Swift - scan is a very similar operator but reduce goes over the complete sequence and gives you the final value of the accumulator while scan emits each intermediate value as well. If you haven’t used reduce - no worries you’ll get to understand scan from the examples below.

Custom bindings with RxSwift

Intro After I did some convenience operators of my own, which really made things easier while writing code I thought I’d be a good idea to look into building more stuff on my own. It helps learning and it’s healthy :) Binding to make a view visible I noticed there is a binding on the hidden property of UIView but sometimes the code just reads better when you don’t have to think of hiding something but rather showing something.

Custom convenience operators with RxSwift, Part 2

Intro I got some great feedback on last week’s post on convenience operators part 1 so I’m really excited to publish part 2, which I hope will be even more interesting for those of you who are looking into RxSwift. Without further ado let’s dive in code… A better negate() operator First of all I have a better version of my negate() operator from last week for you. What I wrote on my own was a pretty simple function that looked like so: extension Observable where Element: BooleanType { public func negate() -> Observable<Bool> { return map {value in !value} } } It doesn’t get simpler than that, right?

Custom convenience operators with RxSwift, Part 1

Intro Just like when learning a new language you need to build up a dictionary to start understanding how the language works, you got to learn the Rx operators and everything will eventually click together. And then once you have a good common of a language it’s okay to start coming up with new words too to boost the expressiveness of your speech and for convenience. Same thing happened with me last week - for the first time I felt like I’m getting work done with RxSwift because I had good understanding how to use at least few operators.

Split laps timer with RxSwift and RxCocoa: Part 2

In my post from last week I worked on creating a split lapse timer app (last week’s post). But later on when I was playing with the application I noticed that I naturally would like to have means to start or stop the timer.

Well this week I am implementing exactly this functionality.

The first thing I thought about was how to implement state in my app because a timer clearly has two distinct states either running or not running. That got me thinking about combining signals, mapping, you know, all the good stuff.

If you want to follow along you can download the starter project I prepared. It is in the shape where last weeks blog posts leaves off but I’ve added a couple of buttons in the user interface:

Download the starter project to follow along here: rx_laptimer_starter.zip

Now let’s put all those buttons to work!


Split laps timer with RxSwift and RxCocoa

I was browsing through RxMarbles and was totally baffled by the sample function. The marble diagram looks pretty random at first sight:

At first I thought - “Hey, that second sequence is getting totally ignored!”. But after I read the description I figured it out:

The first sequence’s elements is what sample emits, while the second sequence’s elements determine when sample emits. So in a way yes - the actual values A, B, C, D do get totally ignored.

When it was clear to me what sample does I started wondering if this function has any practical application :]

This brought me to creating a split lap timer app to test what sample can do for me. In the finished project I have a timer emitting time values (aka the first sequence) and I want to grab (or sample) the values whenever the user taps a button (aka the second sequence).

Here’s how the marble diagram looks like for the app setup:

And this is how the app looks like when finished:

Let’s build that app :]


Manually disposing a bag and creating a timer

I was reading through the RxSwift docs and did a little test to see if I understood manual disposing. As the example made a lot of sense I thought it’s not a bad idea to share it online.