Here is the code.
function getPromise():Promise<any> {
let p = new Promise<any>((resolve, reject) => {
//some logical
resolve(data);
});
p.finally(()=>{
//I want do something when outside then finished!
console.log("finally hit");
});
return p;
}
function doPromise():void {
getPromise().then(data => { console.log("then hit"); });
}
But the finally runs before then. So how can I do something after outside then.
I do not want to add finally after then, because the promise called many places. so I want do it in one place.