This is a webpack 4 frontend architecture series focused on building a frontend scaffold from scratch. It shows how to combine popular modern technologies—React, Redux, webpack 4, and related tooling. It also covers project essentials such as
.gitignore, code formatting, per-environment configuration, hot reload, debugging setup, and similar topics.
How React Interacts With Middleware
- Functional programming ideas
Curried functions defer execution. Middleware built by repeated currying accumulates arguments; with
compose, you get a pipeline-style data flow. - Because of closures, after
applyMiddlewarefinishes, every middleware sees the lateststore.
| |
How it works
Reading the source, applyMiddleware is essentially curry + compose to enhance dispatch. Quick review of curry and compose:
- Implement addition
| |
Now we have one function; add another:
| |
To mirror applyMiddleware, we have a store—it can be more complex; here it is a simple array:
| |
We need compose to chain functions (any number of them). The desired shape:
| |
A minimal compose:
| |
Currying shows up in connect too, but here is a simple implementation:
| |