I have the following typescript code:
var base;
readFile(file, function(e) {
base = e.target.result;
});
alert(base);
The variable "base" gets its value inside the readFile function, and if I do an alert() inside readFile I can see its value without any problem, but if I want to see the value of "base" outside the readFile function it returns undefined .
How can I make the base variable hold the assigned value outside of the readFile function?
Here I also leave the content of the readFile function, which works perfectly:
function readFile(file, onLoadCallback){
var reader = new FileReader();
reader.onload = onLoadCallback;
reader.readAsText(file);
}