I've made a class that, when initialized, starts to download a JSON file.
However, the downloading runs asynchronously. So after I declare it I start working with it, but it fails because it hasn't loaded the file yet.
I could turn async off, but is there another way without freezing the browser?
I'm currently working around it with a setTimeout option, but that seems like an ugly hack.
var d;
$(document).ready(function() {
d = new Duk('element');
d.getBlueprint('hud.json');
setTimeout(start, '2000');
});
function start(){
test = new d.Dialog(d.blueprint.screens.test);
test.draw();
}
setTimeout? Obviously it will be coerced to a number, but why not just use a numeric literal in the first place?Dukand what doesgetBlueprint()do?