A
A
Andrew2017-04-03 11:07:07
React
Andrew, 2017-04-03 11:07:07

Why pass a parameter to the next function from the redux middleware?

As I understand it, we should call next when our amplifier has completed all the necessary operations, and the action is expected as a parameter, we pass the action so that the next middleware understands which action to work with? if we change the action object, will it come to the reducer changed? The action will reach the reducer only when it has passed through all the connected middleware, or maybe something else affects this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Islam Ibakaev, 2017-04-04
@undefined_title

the next function is the next one in the middwara's queue, if there isn't one then it's store.dispatch
your middwara takes an action that exploits it and then passes it on to the next middwara.
To pass on, your current middwara returns the next c action call as an argument, otherwise the action will not reach the reducer (as I understand it, maybe someone will correct it).
middwars are a series of functions that work with an action in turn (usually middwars do side effects, such as outputting an action in the console or requesting some data).
action is dispatched -> middleware series(work with action) -> action reached reducer.
approximately the same scheme as the middleware in express,
a request comes in (request) -> a series of middleware (work with request, form a response) -> a response is returned (response)
If there is no call next() in the express middvr, the application will hang (if I'm not mistaken).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question