Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rui Peres: Testing FRP Code
Search
Realm
July 08, 2016
Technology
86
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rui Peres: Testing FRP Code
Realm
July 08, 2016
More Decks by Realm
See All by Realm
WWDC 2017 Review
realm
0
2.2k
Xcode shortcuts
realm
0
4.8k
Self Branding with GitHub
realm
0
4.4k
Realm Mobile Platform overview and demo
realm
0
2.1k
Realm advanced topics and demo
realm
0
2.1k
Realm introduction Seoul meetup 10
realm
0
2.2k
Stuart Hall: How I got 2.3 Million App Downloads
realm
0
2k
James Majors: What the Swiftly Func?
realm
1
4.3k
Simina Pasat: Continuous everything for iOS apps
realm
0
670
Other Decks in Technology
See All in Technology
Kiro Crewをはじめよう
kizawa2020
1
140
AI時代のAPI開発を加速する品質ガードレール / API Quality Guardrails in the AI Era
yokawasa
0
190
生成AIと進める探索的データ分析(2026.10.03 第122回Tokyo.R勉強会)
tatamiya
2
1.5k
OR学会2026年秋期大会_機械学習と数理最適化の融合による、配合レシピ最適化システム開発事例
brainpadpr
0
130
go-sqletch
moznion
0
130
OpenSharing について熱く語る〜AI アセットの共有について〜
kameitomohiro
0
260
ai_cording_with_k8s_knowledge.pdf
mochizuki875
1
340
Classmethod Company Deck
satoshi7
0
110
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
190
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
140
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
7
2.6k
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
280
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Optimizing for Happiness
mojombo
378
71k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
370
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
720
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Code Review Best Practice
trishagee
74
20k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Docker and Python
trallard
47
4.2k
Practical Orchestrator
shlominoach
192
12k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Transcript
1
BUENOS DÍAS BARCELONA !☀# 2
FRP && TESTING 3
But before we start... 4
SMALL STORY... ! 5
WAY BACK IN 2013... ⏰ 6
FRP + RAC + OBJC ! 7
8
9
10
11
12
13
FRP 101 ! 14
FAMILIAR CONCEPTS... ! 15
KVO + NSOperation + ✨ 16
KVO 17
MutableProperty<T> 18
let foo = MutableProperty(1) // 1. observe foo foo.signalProducer.startWithNext {
newFooValue in print(newFooValue) // prints "1" } // 2. modifiy foo's value foo.value = 2 // 3. prints "2" 19
NSOperation 20
SignalProducer<T, E: ErrorType> 21
let networkCall: SignalProducer<NSData, NSError> = ... let parser: NSData ->
[Painting] = ... let paintingsProducer = networkCall.map(parser) .startOn(QueueScheduler()) 22
paintingsProducer.startWithNext { paintings in print(paintings) // [!, "] } paintingsProducer.on(
failure: { error in // handle error }, next: { paintings in print(paintings) // [!, "] }) .start() 23
✨ 24
25
EXAMPLES... ! 26
Form Validation 27
28
let email: MutableProperty<String> = emailTextField.rex_text let password: MutableProperty<String> = passwordTextField.rex_text
let isValid: (String, String) -> Bool = ... let areCredentialsValid = combineLatest(email.producer, password.producer).map(isValid) loginButton.rex_enabled <~ areCredentialsValid 29
30
Puzzle ! 31
32
33
A plan... ! 34
35
let drinks = SignalProducer<[String], NoError>(value: ["!","!"]) let areSober: [String] ->
Bool = ... let gamePlan = drinks .concat(drinks.delay(7.5)) .concat(timer(5).flatMapLatest { _ in drinks }.takeWhile(areSober)) 36
TESTING FRP ! 37
Discrete 38
func testNumberPaintings() { let expectation = self.expectationWithDescription("Expect to have 2
paintings") defer { self.waitForExpectationsWithTimeout(1.0, handler: nil) } paintingsViewModel.paintingsProducer.startWithNext { paintings in XCTAssertEqual(paintings.count, 2) expectation.fulfill() } } 39
func testNumberPaintings() { let result: Result<[Painting], Error>? = paintingsViewModel.paintingsProducer.first() XCTAssertEqual(result?.value?.count,
2) } 40
Continuous 41
final class StubbedNextValues<T: Equatable> { private var nextValues: [T] private
let expectation: XCTestExpectation init(nextValues: [T] , expectation: XCTestExpectation) { self.nextValues = nextValues self.expectation = expectation } func handleNextValue(nextValue: T) -> Void { guard !nextValues.isEmpty else { fatalError("Can't handle \(nextValue)") } let stubbedValue = nextValues.removeFirst() XCTAssertEqual(stubbedValue, nextValue) if nextValues.isEmpty { expectation.fulfill() } } } 42
let producer: SignalProducer<Int, NoError> = ... let stubbedNextValues = StubbedNextValues(nextValues:
[1, 2, 3, 4], expectation: expectation) producer.startWithNext(stubbed.handleNextValue) 43
FRP takes a while to get used to... ! 44
...testing FRP code is as difficult as you want it
to be ! 45
THANKS @peres 46
47