Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.36 KB

motivation.md

File metadata and controls

39 lines (29 loc) · 1.36 KB
id title hide_title sidebar_label
motivation
Motivation
true
Motivation

Motivation

Problem

Redux and Redux DevTools both work great for following what is happening in your app.1

However, there are three pain points that at least one developer has encountered:

  1. Ugly boilerplate maintenance: one more slice of state = another load of action types, creators and reducers to write.
  2. Unhelpfully named constants: what was NONTRIVIAL_THING_HAPPENED meant to do, again...?
  3. Repetitive reducer logic: an action that updates some slice of state to true? How novel!

1 cf. what you intended to happen in your app...

Solution

redux-leaves is a library that is written to provide:

  1. Pleasingly little boilerplate: set up your reducer and actions in one line
const [reducer, actions] = reduxLeaves(initialState)
  1. Precise updates: easily increment that counter, no matter how deeply you nested it
dispatch(actions.distressingly.and.foolishly.deeply.nested.counter.create.increment(2))
  1. Predictable changes: understand exactly what's happening with clear and consistently named action types:
// action type dispatched above:
'distressingly/and/foolishly/deeply/nested/counter/asNumber.INCREMENT'