--- title: "TCA 演化史:單向資料流如何繁衍成架構雨林" tags: "iPlayground2025" --- {%hackmd ByyUeRW_le %} # 📚 TCA 演化史:單向資料流如何繁衍成架構雨林 ### 👤 講者:Art ### 🕒 時間:15:40 – 16:30 不是滑雪,就是在滑雪的路上 --- ## 🧠 講題摘要 > 從單向資料流出發,TCA 歷經 Dependency、Reducer Protocol、Navigation、Macro、Observation、Sharing State 等七次關鍵「突變」,Point-Free 以實驗般的嚴謹與巧思,逐步把凌亂樣板淬煉成高可測、易組裝的架構雨林。本場次將帶你拆解每一次演化背後的痛點、策略與收穫,一窺現代 iOS 架構的進化路徑。 --- ## 📝 重點筆記 TCA + Swift UI 狀態驅動 -> Swift UI 狀態管理 -> TCA 參考單向資料流 單向資料流的架構,最主要就是 State、Action、Reducer 這三個元件。 View 上面做了一些操作就會送出 Action 然後 Reducer 接受 Action 之後根據之前的 State 會產生出新的 State 最後,State 的變動會驅動 View 的更新。 整個流程其實是單向進行的。 - Unidirectional data flow 單向資料流 - Dependency - Composable 可組合的 解決外部依賴 ### Swift Dependencies (by Point-Free) 不用手動把外部依賴往下傳 ### Modal Presentation (Tree-based Navigation) ### Navigation Path 工具(大改版) (Stack-based Navigation) State 大多是 Value type (放在 RAM Stack memory 中) Debug mode 一打開就閃退 Presentation stack state (reference type for storage type) 放在 Heap memory 中 Copy on write ### Macro Before: case paths After: `@CasePathable` `@Reducer` 大大減少 Boilerplate code iOS 17 Swift Observation Framework -> `@ObservableState` ### Swift Sharing Still by Point-Free --- ## 💬 Q&A / 討論紀錄 - Q: ... - A: ... - Q: ... - A: ... --- ## 🧩 延伸資源 / 投影片連結 - [The Composable Architecture](https://github.com/pointfreeco/swift-composable-architecture) - [13 的 iOS 開發配飯吃 • SwiftUI + TCA 系列](https://www.youtube.com/playlist?list=PL_ISTqHGWkNyN2qbc5wVDRyE6baEQ-BqU) - [Point Free 課程(需額外訂閱)(部分免費)](https://www.pointfree.co/collections/composable-architecture) - [講者示範專案 on Github](https://github.com/jutoart/ColorLove) ## 雜談、心得 - 我也是在演化前開始用,放一陣子之後再回去更新版本,整個是完全不同的世界(所以嚇到棄坑了)。 > 現在應該還算成熟了? 嚇跑人的大改好像比較少了。 > 對現在比較少了,但SwiftUI的bug依然很嚇人Long Live UIKit - 入門時大多會卡三個點: - Templete 產生 - Reducer - 使用了依賴注入(Dependency Injection, DI)概念的 Dependency 系列 Property wrapper - TCA 把很多常用的官方 SDK 功能直接封装在 Dependency 庫裡面, 用 Property wrapper 直接使用,減少直接呼叫產生的依賴。 - 隨著了解背後的理念,會慢慢了解這樣的方式寫起來其實很舒服😌 - 什麼呀 TCA 沒有個穩定的版本嗎。大改了 7 次,是在創造就業機會嗎 lol > TCA的學習曲線已經像是一座山,還大地震了七次。 > ~~決定開發一個 TCA 地震速報的 App。~~ > 13的SwiftUI配飯吃帶我們經歷過每次的災後重建。 > ~~TCA 山崩警告~~ > 山崩之後是比較平緩一點了
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.