I have two javascript files, one is a global file(global.js) that should be accessed by all other javascript files, and the other uses the variables in global.js
Here's a snippet of the code in global.js:
var datasetArray = [];
var queue = d3.queue();
queue.defer(d3.json, "data.json")
.await(loadJson)
function loadJson(error, data) {
//returns the appropriate mapping of the data
districtDataset = data.map(function(d) {...});
datasetArray.push(districtDataset);
}
In the other js file, I am trying to access the data pushed inside the datasetArray. But the file is being loaded async and I cannot access its objects. So my question is, how can i access the array in the other js files after it the appropriate dataset has been pushed?
Thank you :)