Js asynchronous collaboration

Source: Internet
Author: User

Document http://html5ify.com/eventproxy/api.html first

Var EventProxy = require (". /eventproxy'); var proxy = new eventproxy (); var add = function (v1, v2, v3) {console. log (v1 + v2 + v3 + '') ;}; proxy. assign ("v1", "v2", "v3", add); clinet1.get ("key1", function (err, data) {// do something proxy. trigger ("v1", data) ;}); clinet2.get ("data", function (err, data) {// do something proxy. trigger ("v2", data) ;}); clinet3.get ("l10n", function (err, data) {// do something proxy. trigger ("v3", data );});

 

In JS programming, there is often such a need: To generate a page, the data is ajax, the template is also ajax to obtain, the general approach is to first send an ajax request to retrieve data, wait for the permanent request to complete and then send an ajax request to fetch the template, and then render it. In fact, the request data and the request template are both initiated at the same time and can be rendered when both are returned. This eventproxy is something to write for convenience.

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.