ES6 原生的 Promise 只有then 和 catch 没有 finally,谁有靠谱的方式加上?
已知的不太靠谱方法,有自己增加一个属性的方式finally,在里面调用 then 或者 catch 但这样只是一个then和catch的合体,并不是真的finally,它不会排在所有 then 所有 catch之后执行。
例如
promise = new Promise(...)
promise.finally().then()
这里后面的 then 会在 finally之后执行,
而真正的finally 应该在所有的 then 或者 catch 完结以后执行。
手工把finally写最后只是掩耳盗铃,
不能假设从此后这个promise不再增加其他的 then 或者catch
比如
promise.then().finally()
....
if xxx:
promise.then(...)