Skip to content

Instantly share code, notes, and snippets.

@xieranmaya
Created July 17, 2015 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xieranmaya/5f817d85823dcb108fc9 to your computer and use it in GitHub Desktop.
Save xieranmaya/5f817d85823dcb108fc9 to your computer and use it in GitHub Desktop.
Promise.prototype.finally = function(fn) {
function finFn(){
setTimeout(fn)
}
this.then(finFn, finFn)
return this
}
@redyyu
Copy link

redyyu commented Jul 27, 2015

setTimeout 在这里起什么作用?

@sysoft
Copy link

sysoft commented May 3, 2017

PromiseHandle.catch().then(function() {
console.log('这里似乎等同于finally');
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment