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
1k
DIY your own Combine framework
Li-Heng Hsu
September 22, 2019
Tweet
Share
Other Decks in Programming
See All in Programming
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
780
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
2
850
PostgreSQLのRow Level SecurityをPHPのORMで扱う Eloquent vs Doctrine #phpcon #track2
77web
2
530
Quand Symfony, ApiPlatform, OpenAI et LangChain s'allient pour exploiter vos PDF : de la théorie à la production…
ahmedbhs123
0
200
Deep Dive into ~/.claude/projects
hiragram
14
2.6k
Claude Code + Container Use と Cursor で作る ローカル並列開発環境のススメ / ccc local dev
kaelaela
10
5.7k
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
700
AI時代のソフトウェア開発を考える(2025/07版) / Agentic Software Engineering Findy 2025-07 Edition
twada
PRO
91
30k
Is Xcode slowly dying out in 2025?
uetyo
1
280
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
130
AI駆動のマルチエージェントによる業務フロー自動化の設計と実践
h_okkah
0
170
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
2
150
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Typedesign – Prime Four
hannesfritz
42
2.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Agile that works and the tools we love
rasmusluckow
329
21k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
GitHub's CSS Performance
jonrohan
1031
460k
A Tale of Four Properties
chriscoyier
160
23k
Scaling GitHub
holman
460
140k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
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