R
R
Rapen2017-05-10 18:33:43
Node.js
Rapen, 2017-05-10 18:33:43

Confused about asynchrony?

Asynchrony is a synonym (out of order). The concept of asynchrony in node, when the script is not blocked, for example, when loading data, i.e. the script does not wait for this download, but processes it in the background, and the code is processed further, but on the client, just the opposite, if things are with promises, then each function call chain is waiting for each other, that is, in turn.
In redux, in asynchronous actions, the dispatch method won't render until it's loaded from the api (i.e. asynchronous, has the opposite meaning). Can anyone help clear up this mess, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gushchin, 2017-05-10
@Rapen

but on the client, just the opposite, if things are with promises, then each function call chain is waiting for each other, that is, in turn.

This is not true. The chain does not wait for each other - the thread is not blocked, just like node. When a server response arrives, the corresponding callback is called. But while waiting - your code works (for example - you wanted to render a loading animation).
In asynchronous actions, you can change the state (dispatch) whenever you want. This is usually done twice - when the request is sent (initiated) and when the response comes. Between these moments, you can have other actions (the user clicked on a button, or something else happened) and you process them asynchronously.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question