I have what I thought was a simple problem - but I simply can't solve it.
I have a API that I'm using that returns a function
for me to call when all my code is complete. I had thought that I could just put the function in a finally
call - but it seems I can't redefine functions during a promise chain.
A simple example:
let a= function() {console.log("at the start");};
BbPromise.resolve("Executing")
.tap(console.log)
.then(function() {a = function() {console.log("at the end");}})
.finally(a);
How would I go about getting "At the end"
to print out, at the end? This example will always print "At the start"
. If I use strings instead of functions, it works as expected.