You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
🌴
On vacation in Spain
Tony Pai
tpai
🌴
On vacation in Spain
The true beauty of something lies in it fulfilling its purpose.
Saga 的概念有點像 Event Loop,使用 take helpers 觀測 Trigger Action(load) 是否被 Dispatch,進而透過 Generator Function 使用 Call Effect 執行 Async Requests,再用 Put Effect 去 Dispatch 不同階段的 Action(loading, loaded, failed...) 以讓 UI 物件呈現出不同變化。
Learning Redux Saga With Simple Example
The concept of saga is like event loop, take effect/helpers for watching action, call effect for handling async request and put effect for dispatching different stage of actions(loading, loaded, failed...). Unlike thunk get invoked on every actions, saga only run once at the start and process watching in the background. About saga and thunk, two of the most common differences are async task could be cancelled at any moment, and the structure of saga is easy for developer to test different stage of actions.