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
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
210
Nuxt Server Components
wattanx
0
250
それはエンジニアリングの糧である:AI開発のためにAIのOSSを開発する現場より / It serves as fuel for engineering: insights from the field of developing open-source AI for AI development.
nrslib
1
830
3分でわかるatama plusのQA/about atama plus QA
atamaplus
0
110
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
180
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
220
メッセージングを利用して時間的結合を分離しよう #phperkaigi
kajitack
3
560
2026-03-27 #terminalnight 変数展開とコマンド展開でターミナル作業をスマートにする方法
masasuzu
0
300
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
1.7k
Feature Toggle は捨てやすく使おう
gennei
0
430
iOS機能開発のAI環境と起きた変化
ryunakayama
0
160
ネイティブアプリとWebフロントエンドのAPI通信ラッパーにおける共通化の勘所
suguruooki
0
250
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.1k
Balancing Empowerment & Direction
lara
5
1k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
340
ラッコキーワード サービス紹介資料
rakko
1
2.9M
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
30 Presentation Tips
portentint
PRO
1
270
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
The agentic SEO stack - context over prompts
schlessera
0
730
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
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