UNPKG

1.4 kBMarkdownView Raw
1---
2id: motivation
3title: Motivation
4hide_title: true
5sidebar_label: Motivation
6---
7
8# Motivation
9
10## Problem
11
12[Redux](https://redux.js.org/) and [Redux DevTools](https://github.com/zalmoxisus/redux-devtools-extension) both work great for following what is happening in your app.<sup>1</sup>
13
14However, there are three pain points that at least one developer has encountered:
15
161. **Ugly boilerplate maintenance**: one more slice of state = another load of action types, creators and reducers to write.
172. **Unhelpfully named constants**: what was `NONTRIVIAL_THING_HAPPENED` meant to do, again...?
183. **Repetitive reducer logic**: an action that updates some slice of state to `true`? *How novel!*
19
20<sup>1</sup> *cf. what you* intended *to happen in your app...*
21
22## Solution
23
24`redux-leaves` is a library that is written to provide:
25
261. **Pleasingly little boilerplate**: set up your reducer and actions in one line
27```js
28const [reducer, actions] = reduxLeaves(initialState)
29```
30
312. **Precise updates**: easily increment that counter, no matter how deeply you nested it
32```js
33dispatch(actions.distressingly.and.foolishly.deeply.nested.counter.create.increment(2))
34```
353. **Predictable changes**: understand exactly what's happening with clear and consistently named action types:
36```js
37// action type dispatched above:
38'distressingly/and/foolishly/deeply/nested/counter/asNumber.INCREMENT'
39```
40
\No newline at end of file