Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DIY your own Combine framework
Search
Li-Heng Hsu
September 22, 2019
Programming
1.1k
0
Share
DIY your own Combine framework
Li-Heng Hsu
September 22, 2019
Other Decks in Programming
See All in Programming
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
200
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
110
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
570
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
240
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
130
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.2k
AWSはOSSをどのように 考えているのか?
akihisaikeda
0
100
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
110
GitHubCopilotCLIをはじめよう.pdf
htkym
0
330
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
130
AI-DLC Deep Dive
yuukiyo
9
5.7k
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
380
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
Navigating Team Friction
lara
192
16k
Google's AI Overviews - The New Search
badams
0
1k
Odyssey Design
rkendrick25
PRO
2
610
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
Leo the Paperboy
mayatellez
7
1.8k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
130
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
170
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
210
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
280
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Transcript
DIY your own Combine framework Basic Functional Reactive Programming concepts
Li-Heng Hsu 許立衡 @ iPlayground 2019
– Apple documentation "The Combine framework provides a declarative Swift
API for processing values over time."
None
Concepts • Builder pattern • map(_:) method
Builder pattern • For constructing instances • Like initializer, factory
method… 1. Create a builder struct 2. Store construction info in it 3. Call its build() method to construct a product
URLComponents URL builder
Combine Subscription builder
Builder pattern Combine Builder Publisher Construction info Operator build() Subscriber
Product Subscription Roles
CombineDIY.swift
map(_:) method • There are different worlds in code •
World of Uncertainty, World of Plurality, World of Erroneous... • Instances in these worlds can't be manipulated normally
Optional World of Uncertainty
World of Uncertainty Cat? (Cat) -> Double (Cat?) -> Double?
map(_:)
None
Imperative Functional Metaphor Unwrap values Stack operations Optional if let
x = x { /* ... */ } x.map { x in /* ... */ } Collection for i in x { /* ... */ } x.forEach { i in /* ... */ } Result if case .success(let x) = result { /* ... */ } result.map { x in /* ... */ }
World of Plurality [Cat] (Cat) -> Double ([Cat]) -> [Double]
map(_:)
World of Temporality Publisher<Cat> (Cat) -> Double (Publisher<Cat>) -> Publisher<Double>
map(_:)
DIY map(_:)
Feedback Come find me! Twitter: @lihenghsu