We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
finally方法用于指定不管 Promise 对象最后状态如何,都会执行的操作。它的回调函数不接受任何参数,一般用于结束状态。
promise .then(result => {···}) .catch(error => {···}) .finally(() => {···});
原理:不管成功或者失败都调用。
Promise.finally = function (callback) { let P = this.constructor; return this.then( value => P.resolve(callback()).then(() => value), reason => P.resolve(callback()).then(() => { throw reason }) ); };
ECMAScript 6 入门 - 阮一峰
The text was updated successfully, but these errors were encountered:
文不对题
Sorry, something went wrong.
@JasonXiaoSpace 抱歉已经改过来了,issue我懒得维护了有兴趣可以直接看仓库哦
@sihai00 写得挺好竟没star 估计你就没做宣传
@JasonXiaoSpace 谢谢哈哈,先沉淀下
sihai00
No branches or pull requests
手写Promise.finally
finally方法用于指定不管 Promise 对象最后状态如何,都会执行的操作。它的回调函数不接受任何参数,一般用于结束状态。
实现
原理:不管成功或者失败都调用。
参考
ECMAScript 6 入门 - 阮一峰
The text was updated successfully, but these errors were encountered: