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
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
A2A プロトコルを試してみる
azukiazusa1
2
1.3k
今ならAmazon ECSのサービス間通信をどう選ぶか / Selection of ECS Interservice Communication 2025
tkikuc
21
3.9k
PHPで始める振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
2
340
ニーリーにおけるプロダクトエンジニア
nealle
0
780
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
660
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
480
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
160
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
270
スタートアップの急成長を支えるプラットフォームエンジニアリングと組織戦略
sutochin26
0
4.3k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
430
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
5
800
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
5.9k
Adopting Sorbet at Scale
ufuk
77
9.4k
Code Review Best Practice
trishagee
69
18k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Fireside Chat
paigeccino
37
3.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
Practical Orchestrator
shlominoach
188
11k
Designing for humans not robots
tammielis
253
25k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
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