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
1k
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
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
39
1.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
A Tale of Four Properties
chriscoyier
158
23k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
113
50k
Building Applications with DynamoDB
mza
93
6.2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
20
2.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
The Cult of Friendly URLs
andyhume
78
6.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Designing Experiences People Love
moore
139
23k
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 はコンパイルの段階で、 副作用に伴う状態の変化と副作用 を分離