Redux Middleware => Code Perspective

We will be concentrating more on the inner workings of applyMiddleware function

Currying of Functions

  1. pass all the arguments a function is expecting and get the result or
  2. pass a subset of those arguments and get back a function that’s waiting for the rest of the arguments.

Walkthrough of the code

  1. Each middleware is given the `dispatch` and `getState` functions as named arguments and array ‘chain’ holds the returned intermediate functions which are of the signature next => action. The intermediate function are given the ‘next’ middleware’s dispatch method and is expected to return a function of action calling next(action).
  2. The new dispatch function is composed from the chain array and the store’s dispatch is sent to the last (rightmost) function(in the chain) as the ‘next’ parameter.

--

--

JavaScript Dev with an affinity to React. https://anooprav7.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store