Skip to content

Commit a0f63cd

Browse files
committed
patch/doc: added redux toolkit comparison images
1 parent 87d2925 commit a0f63cd

File tree

3 files changed

+40
-31
lines changed

3 files changed

+40
-31
lines changed

README.md

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,18 @@ The result is a elegant API with 2-3x reduction in client code and near total el
1414
1515
## Contents
1616

17-
1. [ Install ](#install)
18-
1. [ Usage ](#usage)
19-
1. [ Comparison ](#comparison)
20-
1. [ Tutorial ](#tutorial)
21-
1. [ API ](#api)
22-
1. [ How it Works ](#how-it-works)
23-
1. [ TypeScript ](#typescript)
24-
1. [ Prior Work ](#prior-work)
25-
1. [ Contribution ](#contribution)
26-
1. [ License ](#license)
27-
1. [ Produced at GenUI ](#produced-at-genui)
28-
29-
Additional resources:
30-
31-
* 1st blog post: [How I Eliminated Redux Boilerplate with Hooks-for-Redux](https://medium.com/@shanebdavis/how-i-eliminated-redux-boilerplate-with-hooks-for-redux-bd308d5abbdd)
32-
* 2nd blog post: [The 5 Essential Elements of Modular Software Design](https://medium.com/@shanebdavis/the-5-essential-elements-of-modular-software-design-6b333918e543)
33-
* 3rd blog post: [Modular Redux — a Design Pattern for Mastering Scalable, Shared State in React](https://medium.com/@shanebdavis/modular-redux-a-design-pattern-for-mastering-scalable-shared-state-82d4abc0d7b3)
34-
35-
Included Examples:
36-
37-
* [tiny](./examples/tiny) - the simplest working example
38-
* [tiny-todo](./examples/tiny-todo) - a slightly more detailed example
39-
* [middleware](./examples/middleware) - an example of how to use Redux middleware with H4R
40-
* comparison [plain-redux](./examples/comparison-plain-redux) vs [hooks-for-redux](./examples/hooks-for-redux) - compare two, tiny working examples back-to-back
41-
42-
Advanced Examples:
43-
* [todo with filters](https://github.com/shanebdavis/rtk-convert-todos-example-h4r-conversion) (try it now on [codesandbox.io](https://codesandbox.io/s/github/shanebdavis/rtk-convert-todos-example-h4r-conversion))
44-
* [github-issues-browser](https://github.com/shanebdavis/rtk-github-issues-example-h4r-conversion) with typescript and asynchronous requests (try it now on [codesandbox.io](https://codesandbox.io/s/github/shanebdavis/rtk-github-issues-example-h4r-conversion))
45-
17+
1. [ Install](#install)
18+
1. [ Usage](#usage)
19+
1. [ Comparison](#comparison)
20+
1. [ Tutorial](#tutorial)
21+
1. [ API](#api)
22+
1. [ How it Works](#how-it-works)
23+
1. [ TypeScript](#typescript)
24+
1. [ Prior Work](#prior-work) (Redux Toolkit and others)
25+
1. [ Additional Resources](#additional-resources)
26+
1. [ Contribution](#contribution)
27+
1. [ License](#license)
28+
1. [ Produced at GenUI](#produced-at-genui)
4629
## Install
4730

4831
```
@@ -556,12 +539,16 @@ H4R solution
556539
* source: [github](https://github.com/shanebdavis/rtk-convert-todos-example-h4r-conversion)
557540
* ~160 lines of JavaScript
558541

559-
Here is a roughly apples-to-apples slice of the code from each project:
542+
Here is an apples-to-apples comparison of some of the main files from each project:
560543

561544
* [Redux Toolkit gist - 104 lines](https://gist.github.com/shanebdavis/9e67be8a0874a4c295001ba6e91f79e2)
562545
* [Hooks-for-redux gist - 52 lines](https://gist.github.com/shanebdavis/ce02b4495f1bc0afa830796f58124604)
563546

564-
Part of the key is how well H4R links into React. Redux-toolkit takes 50 lines of code just to do this:
547+
Perhaps the most dramatic difference is how H4R simplifies the interdependencies between files. Boxes are files, lines are imports:
548+
549+
![](assets/h4r-vs-reduxToolkit-intermediate-example.png)
550+
551+
Part of the key is how well H4R links into React. Redux-toolkit takes 50 lines of code just to do this.
565552

566553
```javascript
567554
import React from 'react'
@@ -641,6 +628,28 @@ H4R solution:
641628
* source: [github](https://github.com/shanebdavis/rtk-github-issues-example-h4r-conversion)
642629
* ~613 lines of TypeScript
643630
631+
The file and inter-file dependency reduction is dramatic. With H4R your code will be significantly more agile and easier to adapt to new changes. Boxes are files, lines are imports:
632+
633+
![](assets/h4r-vs-reduxToolkit-advanced-example.png)
634+
635+
## Additional Resources
636+
Blog Posts:
637+
638+
* [How I Eliminated Redux Boilerplate with Hooks-for-Redux](https://medium.com/@shanebdavis/how-i-eliminated-redux-boilerplate-with-hooks-for-redux-bd308d5abbdd) - an introduction and explanation of H4R with examples
639+
* [The 5 Essential Elements of Modular Software Design](https://medium.com/@shanebdavis/the-5-essential-elements-of-modular-software-design-6b333918e543) - how and why to write modular code - a precursor to why you should use Modular Redux (e.g. H4R)
640+
* [Modular Redux — a Design Pattern for Mastering Scalable, Shared State in React](https://medium.com/@shanebdavis/modular-redux-a-design-pattern-for-mastering-scalable-shared-state-82d4abc0d7b3) - the Modular Redux design pattern H4R is based on and detailed comparison with Redux Toolkit
641+
642+
Included Examples:
643+
644+
* [tiny](./examples/tiny) - the simplest working example
645+
* [tiny-todo](./examples/tiny-todo) - a slightly more detailed example
646+
* [middleware](./examples/middleware) - an example of how to use Redux middleware with H4R
647+
* comparison [plain-redux](./examples/comparison-plain-redux) vs [hooks-for-redux](./examples/hooks-for-redux) - compare two, tiny working examples back-to-back
648+
649+
Advanced Examples:
650+
* [todo with filters](https://github.com/shanebdavis/rtk-convert-todos-example-h4r-conversion) (try it now on [codesandbox.io](https://codesandbox.io/s/github/shanebdavis/rtk-convert-todos-example-h4r-conversion))
651+
* [github-issues-browser](https://github.com/shanebdavis/rtk-github-issues-example-h4r-conversion) with typescript and asynchronous requests (try it now on [codesandbox.io](https://codesandbox.io/s/github/shanebdavis/rtk-github-issues-example-h4r-conversion))
652+
644653
## Contribution
645654
646655
If you have suggestions for improvement, please feel free to [start an issue on github](https://github.com/generalui/hooks-for-redux/issues).
359 KB
Loading
197 KB
Loading

0 commit comments

Comments
 (0)