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
440
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
Fantastic passwords and where to find them - at NoRuKo
philnash
39
2.5k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
660
120k
We Have a Design System, Now What?
morganepeng
43
6.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Statistics for Hackers
jakevdp
790
220k
How to train your dragon (web standard)
notwaldorf
75
5.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
For a Future-Friendly Web
brad_frost
172
9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
245
20k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
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 はコンパイルの段階で、 副作用に伴う状態の変化と副作用 を分離