We are used to using traditional callbacks or event handling to solve asynchronous problems
Event: A property of an object is a function that is run when something happens
dom.onclick = function(){}Copy the code
Callback: When you run a function to implement a function, you pass in a function as an argument, and the function is run when something happens.
dom.addEventListener("click".function(){})Copy the code
In essence, there is no essential difference between events and callbacks, just where functions are placed.
The model has worked well.
Until the front-end engineering got more complex…
At present, this mode mainly faces the following two problems:
- Callback hell: An asynchronous operation that waits for a previous asynchronous operation to complete is trapped in constant nesting, either with callbacks or events
- Connections between asynchronous operations: Dealing with connections where an asynchronous operation waits for the results of multiple asynchronous operations can increase code complexity dramatically