Android Flux

觀念

Dispatcher

讓「有註冊到 Dispatcher 的 Store」都能收到 ActionCreator 發送的 Action。

Action

Action 是一個 Event Object ,用來通知 Store 有新的 Action 並且能識別該 Action 的類型,讓 Store 知道要不要處理收到 Action

ActionCreator

提供一個元件來規範建立 Action 並且傳送給 Dispatcher的機制。

Store

收到 Action 後,進行一些處理,像是更新 db 或是更新 ArrayList,然後再通知 View 更新 UI。

View

整個流程有 2 個地方會使用到 View,就是開頭跟結束的時候。
1. 當 User 操作 View 時,會使用 ActionCreator 建立新的 Action
2. 接受 Store 的通知,事情都處理完了,可以更新 UI 了。

參考資料

AndroidFlux项目一览-Flux架构的Android移植
AndroidFlux-异步请求和网络

0 意見:

張貼留言