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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
110
AtCoder Conference 2025
shindannin
0
1.1k
MUSUBIXとは
nahisaho
0
130
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
300
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
240
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
280
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
190
組織で育むオブザーバビリティ
ryota_hnk
0
180
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
Featured
See All Featured
Believing is Seeing
oripsolob
1
55
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.4k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
How to train your dragon (web standard)
notwaldorf
97
6.5k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
93
Ruling the World: When Life Gets Gamed
codingconduct
0
140
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
0
2.3k
Code Review Best Practice
trishagee
74
20k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
120
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
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