Event mechanism, transfer Function, the combination of the two, just right, function just right

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.