相关疑难解决方法(0)

关于Promises/A +规范,术语"可以"和"承诺"之间有什么区别?

我正在检查"Promises/A +"规范,但无法理解以下内容:

在第1节.术语,

1.1."promise”是一个具有then方法的对象或函数,其行为符合此规范.

1.2.“thenable”是定义then方法的对象或函数.

那么术语"thenable"和有"promise"什么区别?

同样在2.3节.承诺解决程序,

promise解析过程是一个抽象操作,它将promise和value作为输入,我们将其表示为[[Resolve]](promise, x).

所以我的问题是:

为什么在2个开始和结束括号内表示?有没有约定?

非常感谢你.

javascript specifications specification-pattern promise

25
推荐指数
2
解决办法
2621
查看次数

用另一个承诺履行(不解决)承诺

我希望履行一些其他承诺的承诺.关键是我真的希望在第一个承诺完成后立即获得(仍在等待的)第二个承诺.不幸的是,一旦两个承诺都得到满足,我似乎只能获得第二个承诺的分辨率值.

这是我想到的用例:

var picker = pickFile();

picker.then(  // Wait for the user to pick a file.
    function(downloadProgress) {
        // The user picked a file. The file may not be available just yet (e.g.,
        // if it has to be downloaded over the network) but we can already ask
        // the user some more questions while the file is being obtained in the
        // background.

        ...do some more user interaction...

        return downloadProgress;
    }
).then( // Wait for the download …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 es6-promise

7
推荐指数
1
解决办法
3235
查看次数