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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DIY your own Combine framework
Li-Heng Hsu
September 22, 2019
Other Decks in Programming
See All in Programming
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
180
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
200
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
280
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
450
Built Our Own Background Agent at LayerX #aidevex_findy
layerx
PRO
9
4.3k
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
240
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
290
その節約、円になってますか?
isamumumu
1
640
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
200
AIエージェントで 変わるAndroid開発環境
takahirom
2
760
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
190
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
190
Featured
See All Featured
The SEO Collaboration Effect
kristinabergwall1
1
510
A Modern Web Designer's Workflow
chriscoyier
698
190k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Exploring anti-patterns in Rails
aemeredith
3
450
Into the Great Unknown - MozCon
thekraken
41
2.6k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
200
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
360
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
310
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
400
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
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