Event mechanism, transfer Function, the combination of the two, just right, function just right
The world is diverse. Only by organically integrating different things can we achieve "natural harmony.
The event mechanism is an effective means of transmitting information, but it is not the "only" or "best" (because there is no so-called "best").
It has its applicability, that is, it is not the most suitable for some occasions.
For example, DropDown and DateChooser components with pop-up forms. The pop-up forms are displayed in the form of stage. addChild (window.
That is to say, only the stage. addEventListener () method can be used to listen to events in the form. However, the component cannot monitor events triggered by the form.
This is awkward. The code structure is not natural.
In addition, the event mechanism provides a convenient way to transmit information, which also leads to "information leakage".
"Closed" difference.
When selecting and designing data transmission methods, we should also pay attention to the "natural harmony" described in nature.
Meaning that the code structure is concise, reasonable, and easy to understand.
This is important for the design of component structures and mechanisms.
A callback function can be set up between parent and child components to transmit information.
This structure and mechanism ensures that the data is "closed" and will not spread out, and is easy to use. It also reduces the performance overhead of event listeners.