1616 changes in front-end App framework design ideas-from pull to push

Source: Internet
Author: User

The observer mode is divided into two modes: "push" and "pull.

 

Examples of daily life: paper. The reporter sent us to the portal. This is the push mode; we picked it up at the newsstand. This is the PULL mode.

The difference between the two in code is as follows: when a notification comes, the notification function does not contain any relevant information, but requires the subscriber to actively pull the information; when a notification comes, the push mode pushes all relevant information to the subscriber in the form of parameters. For more information, see. Assume that the App is a message subscriber, the SubjectBase and Subject are message producers, and the Observer is an intermediary Observer.

It is difficult to interact between old framework apps. Many custom events need to be extended on the Framework end, and other apps can implement event response functions. If you use the old framework, it is very difficult to customize an event. First, you need to modify the notify () implementation in the old framework, and then the App needs to implement the response function of the Custom Event, we also need to handle event fault tolerance (some apps do not implement the Event Response Function), that is, both the framework and the specific App must be enabled.

After some requirement evolution, the App also has the Subject's "Publish notification" capability, that is, "Any APP can send notifications and listen for messages of interest to it ", eventually evolved.

Is it much simpler? This idea eventually facilitates the convenience of customizing App events and facilitates interaction between apps. For example, if App1 wants to define an event and App2 wants to listen to this event of App1, you only need App2.listen ("Custom Event 1") and app1.y y ("Custom Event 1", "additional data. In this way, all the modifications are made to the specific App. 1616, as an upcoming App platform, is wise to delegate autonomy to App developers. Of course, the "Custom Event 1" event name is agreed upon by the two apps. Otherwise, the event name is incorrect and will not respond. This is important.

In general, the push mode can reduce coupling more, and the maintenance is easier to change, but the disadvantage is that no information is useful and pushed to the App. However, the front-end uses javascript to communicate, and the overhead of transmitting redundant information in the push mode is almost negligible, because the javascript program runs on the user's local computer and the transmission speed is quite fast.

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.