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
0
1.1k
DIY your own Combine framework
Li-Heng Hsu
September 22, 2019
Tweet
Share
Other Decks in Programming
See All in Programming
The free-lunch guide to idea circularity
hollycummins
0
210
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
110
どんと来い、データベース信頼性エンジニアリング / Introduction to DBRE
nnaka2992
1
290
Understanding Apache Lucene - More than just full-text search
spinscale
0
120
文字コードの話
qnighy
44
17k
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
320
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
200
Ruby and LLM Ecosystem 2nd
koic
1
840
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
230
TipKitTips
ktcryomm
0
170
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
560
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
240
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
250
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
160
Accessibility Awareness
sabderemane
0
81
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Technical Leadership for Architectural Decision Making
baasie
3
290
Embracing the Ebb and Flow
colly
88
5k
Odyssey Design
rkendrick25
PRO
2
550
Scaling GitHub
holman
464
140k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
Agile that works and the tools we love
rasmusluckow
331
21k
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