Memoization

This post comes from this tweet shared by David Rodrigues (if you don't follow him on Twitter you should): If you have a closure that needs some internal state to be used and modified between executions of the closure you can declare your state as part of the capture list,…

RAS S1E4

Flatmap is one of those ubiquitous operators that, independently of your expertise level, will be present in your day-to-day work with ReactiveSwift. In this post I will talk about how we can leverage its strategies with an example. If you are not familiar with them: latest race merge concact concurrent[…

map versus flatMap

Note: The goal of this post is to give the reader an intuition about the usage of a map versus a flatMap, instead of playing around with return types of each operation, until you pick the one that suits. A recurring topic during our interview process is "what's the…

RAS S1E2

A tale of composition 🌳 In my mind there are two ways of thinking about composition, when we have FRP or FP in the mix. The first one is often mentioned when compared to inheritance[1]: Composition over inheritance in object-oriented programming is the principle that classes should achieve polymorphic behaviour…

Cakes and ViewModels

A talk that I think went fairly unnoticed, by Jon Sterling, entitled "Modularity à la Taliban" stated the following: A ViewModel should only be created by another ViewModel. [1] With this idea in mind, let's see it in practise[1:1]: User tries to login via Facebook. Has…

Younger self

What I wish I could tell my younger self about FRP (from a RAC perspective): Before diving into FRP, start using functional aspects that Swift gives you for free. Like: map, flatMap, filter, reduce, or create your own. This will make the usage of high order functions more intuitive. Without…

Cells and ViewModels

With MVVM, each cell will have its own ViewModel from where it will get the necessary data it needs. That's pretty sweet, until you have to dequeue a cell: So, what's the identifier? The ViewModel shouldn't be aware of the View. And the reason why is: if at any point…

Why FRP?

So today I wrote this on Twitter: People still think that Reactive libs/frameworks are just an enhanced KVO. #2016— Rui Peres (@peres) January 7, 2016 Part 1 And I got some feedback from Miguel Ferreira. Since, in general, I agree with his opinions about software development, I decided…

Schedulers

When you think about ReactiveCocoa, one immediately thinks about Signals, streams of events and transformations. Although that's all there, RAC is more than meets the eye. Lately I had to do the following: Track if a user spends more than 2 seconds in a screen. I went with viewDidAppear: and…

#2 Diary of a Secret App: AutoLayout

I had a rough battle with AutoLayout these days[1]. The following notes are in the context of a UITableView with dynamic sizing cells. : If you want to change an UITableViewCell's layoutMargins, don't use Interface Builder. After some time tracking this down, it seems that if you set contentView's "…