I have a tracker in one of my classes, this class imports a variable from another class that does some computations and returns a array of objects. I am then trying to populate a table with this data. It usually works find when I am pulling data for the db, because the tracker puts a dependency on that that but when I am using an array It does not seem to put a dependency on the variable and only running the tracker once which in turn returns a half empty array.
As you can see in this example I have badDebtsNameSpace is the array variable imported from another class. But it always returns undefined .
Tracker.autorun(function() { // Tracker function for reactivity
if(typeof badDebtsNameSpace.globalDebCalc != "undefined"){
cashInData[0] = badDebtsNameSpace.globalDebCalc['fromOpeningDeb'];
cashInTable.loadData(cashInData);
cashInTable.render();
}
console.log(badDebtsNameSpace)
});
How ever if I look at the printed data from the console log everything seems to be fine. Any ideas on why this is happening.
Thanks
Update
More code as requested. Here is some of the output class that exports the variables.
export var prodNameSpace = {};
export var overheadsNameSpace = {};
export var fixedAssetsName = {};
export var fundingNameSpace = {};
export var globalDebCalc;
export var badDebtsNameSpace;
export var productSummary;
export var assetSummary;
export var vatSummary;
export var overheadsSummary;
export var fundingSummary;
//Overheads Tracker TO Calc Data
Tracker.autorun(function() { // Tracker function for reactivity
var tempData = Session.get('data');
var overs = Overhead.find({fileId: tempData._id}).fetch();
var globalData = GlobalWhatIfData.find({fileId: tempData._id}).fetch();
if(overs.length > 0 && globalData.length > 0){
for(var i in overs){
var percentageOf = PercentageOfData.find({parentId: overs[i]._id}).fetch();
var vatRef = VatDataRef.find({parentId: overs[i]._id}).fetch();
if(percentageOf.length > 0 && vatRef.length > 0){
var n = overs[i].description;
overheadsNameSpace[n] = new OverheadCalc(productSummary, percentageOf, vatRef, globalData);
}
}
overheadsSummary = new OverheadsCalc(overheadsNameSpace);
}
});
//Bad Debt Tracker
Tracker.autorun(function() { // Tracker function for reactivity
var tempData = Session.get('data');
var bds = BadDebts.find({fileId: tempData._id}).fetch();
var globaDeb = GlobalDebtors.find({fileId: tempData._id}).fetch();
if(bds.length > 0 && globaDeb.length > 0){
for(var i in bds){
badDebtsNameSpace = new BadDebtsCalc(bds, productSummary, globaDeb);
}
}
});