Example introduced insection 7
1. Layered architecture (4 layers)
2. Uni-directional data flow (with RxJava2)
3. Custom scope (Dagger2)
5.
Base idea oflayered architecture
View
ViewModel Service Repository
action: Completable
(fetch data)
action: Completable
(fetch data via API)
action: Completable
(set data in repository)
observeData: Flowable
(actually BehaviorProcessor)
observeXXX: Flowable
(calculate values)
observeXXX: Flowable
(calculate values for view)
Look “if actions complete or error”
Look “values”
6.
Today’s topic :How’s in case of interactive view?
State changes
by user’s operation
Fields have dependencies
each other
7.
Two types ofstate
● Domain state
○ 出品に関わるstate
○ 商品名、サイズ、配送方法 ...など、出品時にサーバへ送る重要な値から構成される
● View state
○ 表示に関する状態で、出品そのものには影響しない state
○ 例えば「ポップアップは一度ユーザが closeしたら、2度は出さない」といったユースケースで管
理すべき状態
ViewModel Service Respository
View state Domain stateSet input
8.
Boundary of lifecycle
ViewModelService Respository
View state Domain state
出品開始〜完了 (中断) が生存期間
Activity/Fragmentの
lifecycle
そして、Activityがいつ破壊されようが、再生成された時に
ViewModelへbindすることで即座に画面の状態が復元されるようにする