$30 off During Our Annual Pro Sale. View Details »
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
0
1k
DIY your own Combine framework
Li-Heng Hsu
September 22, 2019
Tweet
Share
Other Decks in Programming
See All in Programming
愛される翻訳の秘訣
kishikawakatsumi
3
330
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
150
なあ兄弟、 余白の意味を考えてから UI実装してくれ!
ktcryomm
11
11k
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
340
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
5.7k
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
130
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
500
SwiftUIで本格音ゲー実装してみた
hypebeans
0
380
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
440
マスタデータ問題、マイクロサービスでどう解くか
kts
0
100
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
140
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1032
470k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Docker and Python
trallard
47
3.7k
Writing Fast Ruby
sferik
630
62k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
730
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Scaling GitHub
holman
464
140k
Designing for Performance
lara
610
69k
How GitHub (no longer) Works
holman
316
140k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
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