Presented below is the code snippet:
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 {
a.getPromise().then(data => { console.log("then hit"); });
}
The issue here is that finally runs before then. How can I execute something after the outside then block?
I prefer not to add finally after each then statement due to multiple calls to the promise. Is there a way to handle this in a single place?