Hacker News new | ask | show | jobs
by acemarke 2371 days ago
That's actually kind of the point.

When you mentally model an action as a "setter", like `SET_PIZZAS_ORDERED`, the reducer usually has almost no logic and just blindly accepts whatever value was in the action. The work of calculating the value was done before the action was dispatched.

If you model actions conceptually as "events", the corollary is that the work of calculating the new state typically ends up in the reducer.

1 comments

Again no, these are modeled as events around a thunk: dispatch START_SEARCH, -> ajax -> any necessary complex logic -> dispatch RESULTS_RECEIVED or QUERY_FAILED. Multiple reducers listen to the same events, acting as simple setters.