Giter Club home page Giter Club logo

Comments (9)

otakustay avatar otakustay commented on June 21, 2024

串行不是一路then就行了吗?

a.then(b).then(c).then(d).fail(handleError);

from er.

strwind avatar strwind commented on June 21, 2024

这样在回调中写下一个请求,要是多有几个,会感觉到嵌套过深

from er.

otakustay avatar otakustay commented on June 21, 2024

能不能看看你们现在的代码会是怎么样子的……我感觉这2个代码:

fetchData()
    .then(processData)
    .then(generateTableContent)
    .then(displayTable);
Deferred.series(
    fetchData,
    processData,
    generateTableContent,
    displayTable
);

连缩进数量都是一样的……

from er.

strwind avatar strwind commented on June 21, 2024

额···估计我表述没太清楚,
是下面这种情况

fetchData()
    .then(function () {
        //Todo
        fetchData2().then(function() {
            //Todo
            fetchData3().then ...
         });
    })

我理解的串行加载是这样的,一个ajax接着一个ajax

from er.

otakustay avatar otakustay commented on June 21, 2024

不是应该这么写吗:

fetchData()
    .then(fetchData2)
    .then(fetchData3)
    .then ...

效果是一样的,你这么写就是没用好Promise吧……

from er.

strwind avatar strwind commented on June 21, 2024
fetchData()
    .then(fetchData2)
    .then(fetchData3)
    .then ...

这种写法我以为fetchData2、fetchData3是平级的,他们之间没有先后关系,不存在依赖··· 不知道是不是我理解then错了···汗

from er.

otakustay avatar otakustay commented on June 21, 2024

所谓then,就是一件事做好then做另一件事嘛,英语啊英语……然后then会把上一个callback的return值送到下一个callback作为参数,所以fetchData2会收到fetchData得到的数据,下面也一样

from er.

strwind avatar strwind commented on June 21, 2024

嗯 只要fetchData3能得到fetchData2的数据就好了··· 看来then确实我没理解透彻,我以为then是把handler都放到一个数组中,然后循环一把都执行了···汗···

from er.

strwind avatar strwind commented on June 21, 2024

最终问题是在then中忘记return了~~~巨汗~~

from er.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.