See: http://heroicyang.com/blog/javascript-event-loop.html
After reading this sentence, I did not understand why an Event Callback is appended to the end of the team when executing this sentence.
status.innerText = 'doing...please wait...';
That is, Because Dom update is involved, another thread is triggered by Dom change event, so it is placed at the end of the team ".
Therefore, I reviewed the C # event delegation mechanism first, hoping to consolidate the Foundation from the elegant and concise C # syntax and find breakthroughs.
For more information, see http://www.codeproject.com/Articles/1474/Events-and-event-handling-in-C.
For more information, see the description section.
Summary:
In the C # syntax, the delegate (delegate) is a keyword, similar to the class that defines the class, which defines the delegate type.
The delegate type is generally named xxxeventhandler, indicating the person who handles certain events.
Its purpose is only to declare a method signature. All methods that comply with the method signature can be mounted to an instance of the delegate type, that is, event.
For example, click, DoubleClick, keypress, and so on. For these different events, as long as the signatures of the methods to be processed are consistent, they can share a type of delegation.
The purpose of mounting is to trigger all mounted Methods One by one when this event is triggered to complete the Event Callback mechanism.
It can be visually interpreted as N people's subscriptions. The mounting action is to subscribe to a newspaper. In the future, whenever the newspaper is distributed, all subscribers will receive it.
The so-called subscriber, observer, and listener are similar descriptions, that is, after an event is triggered, all the subscribed/listened/observed objects of the event can receive notifications so that they can perform different callback actions.
The trigger method corresponding to the event, which is generally named onxxxevent (), such as onclick (). Its implementation is all the methods that trigger mounting on the event.
Every method mounted on the event generally comes with each xxxlistener.
Next we will return to the Javascript world:
status.innerText = 'doing...please wait...';
In fact, the DOM (or HTML) content has been changed, and the system will trigger the DOM changed event, that is, to call back all the methods mounted on the event one by one.
Because Event Callback is asynchronous and the number of events is unknown (depending on how many objects have listened to/subscribed to this event), you do not need to execute the event synchronously immediately, but simply append each method to the queue.
At least one callback is the repaint action of the GUI rendering thread.
This is why an Event Callback is arranged to the end of the team after this sentence is executed.
I think the correct expression should be "because the DOM change event is triggered and a set of asynchronous Callbacks are generated, each callback method is appended to the queue, it must include the repaint method that the GUI rendering thread is responsible."
BTW and handler mean "people who start to handle things, dog trainers, boxing coaches, and managers". They can be understood as the objects for handling events.
Handle has the meaning of "handle, handle, and handle", so handle is translated into "handle" in some places ".