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
TCAにおける副作用の分離
Search
Yuya Okuse
March 18, 2024
0
1.3k
TCAにおける副作用の分離
2024/03/18開催の【iOS】TCAでわいわいLT会における発表資料です。
https://uzabase-tech.connpass.com/event/309323/
Yuya Okuse
March 18, 2024
Tweet
Share
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
Gamification - CAS2011
davidbonilla
81
5.3k
Typedesign – Prime Four
hannesfritz
42
2.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Writing Fast Ruby
sferik
628
61k
How to Ace a Technical Interview
jacobian
277
23k
We Have a Design System, Now What?
morganepeng
53
7.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Facilitating Awesome Meetings
lara
54
6.4k
Transcript
1 Yuya Okuse TCAにおける副作用の分離 TCAでわいわいLT会 Yuya Okuse Yuya Okuse 2024/03/18
自己紹介 2 • Yuya Okuse • 株式会社ディー・エヌ・エー23新卒 • SWET 第二グループ
• iOS アプリエンジニア(Swift) ◦ 2023/07 ~ • TCA ◦ 2024/02 ~
お話すること 3 TCA における副作用の分離
TCA • The Composable Architecture • 以下の課題を解決: ◦ State management
◦ Composition ◦ Side effect ◦ Testing ◦ Ergonomics 4 https://github.com/pointfreeco/swift-composable-architecture
TCA • The Composable Architecture • 以下の課題を解決: ◦ State management
◦ Composition ◦ Side effect ◦ Testing ◦ Ergonomics 5 https://github.com/pointfreeco/swift-composable-architecture
Personal Access Token による GitHub ログイン 6
非同期処理が実行できない 7 Cannot pass function of type '(inout LoginFeature.State, LoginFeature.Action)
async -> Effect<LoginFeature.Action>' to parameter expecting synchronous function type Error:
非同期処理が実行できない 8 クロージャでは非同期関数が使用できない
非同期処理を実行するために 9 クロージャ内で非同期関数を実行可能
可変な変数をキャプチャできない 10 Mutable capture of 'inout' parameter 'state' is not
allowed in concurrently-executing code Error:
Reduce struct と static func run 定義 11 inout 引数
@Sendable
可変な変数をキャプチャできない 12 Mutable capture of 'inout' parameter 'state' is not
allowed in concurrently-executing code Error:
13 成功時 失敗時
状態(State)の変化 14
副作用 15
16 TCA はコンパイルの段階で、 副作用に伴う状態の変化と副作用を分離 副作用の分離
副作用が分離されたことによる利点 17 • 副作用に対する状態変化の把握が容易 • Reducer 内に状態管理を限定することで、 意図しない(未知の)状態変化が起きない 状態管理が容易
状態(State)の変化 18
副作用が分離されたことによる利点 19 • 副作用に伴う 状態の更新(UI 変更)ロジックが 疎結合であるため、テストが容易 ◦ https://github.com/pointfreeco/swift-dependencies •
副作用を含むロジックは、独立して単体テスト が可能。 テスト容易性の向上
まとめ 20 TCA はコンパイルの段階で、 副作用に伴う状態の変化と副作用 を分離