淺談 Redux Thunk

CTJS 閃電講


仰賴 React 開發 Web、Mobile、Desktop
的一介實習生

黃 胤翔

Yin

Thunkify

A thunk is a function that wraps an expression to delay its evaluation.

Dan Abramov

惰性求值

(Lazy Evaluation)

求值策略

  • Call by Value

  • Call by Reference

  • Call by Name (Need)

Thunk=延

一延再延
不到最後一刻不執行

非同步 Action

Why

Redux Thunk

  • 有非同步的需求

  • Action Creator 是 Pure Function

  • 擴充 Middleware

Redux Thunk 核心

ApplyMiddleware

withExtraArgument

總結一下

  • 為了非同步 Action 而誕生的 Middileware

  • 以 Thunk 的方式去延遲

  • 非同步 Function、Logger 等功能的擴充點

References

Thanks for Listening

Redux Thunk

By hinx

Redux Thunk

2016 CTJS Lightning Talk

  • 966