Skip to content

Commit

Permalink
Fix out of order load for multi cell import
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwmwong committed Nov 4, 2010
1 parent ab90ebe commit 3bbb058
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 48 deletions.
33 changes: 17 additions & 16 deletions dist/current/cell-noRenderers.js
Expand Up @@ -808,25 +808,26 @@ require.def('cell/cell-require-plugin',
if(!cellsToLoad.every(isString)){
throwError('cell/cell-require-plugin.load(): only accepts string or array of cell names');
}
var cellsToLoadMap = {};
var loadedCells = [];
cellsToLoad.forEach(function(c,i){
cellsToLoadMap[c] = i;
});
var loadCb = function(dep,e){
if(loadedCells !== null){
if(e){
loadedCells = null;
}else{
loadedCells[cellsToLoadMap[dep.name]] = dep;
if(loadedCells.length == cellsToLoad.length){
var cbArgs = loadedCells;
var cellsToLoadMap = cellsToLoad.reduce(function(r,c,i){r[c]=i; return r;},{}),
loadedCount = 0,
loadedCells = [],
loadCb = function(dep,e){
if(loadedCells !== null){
if(e){
loadedCells = null;
cellLoadCallback.apply(null,cbArgs);
}else{
var index = cellsToLoadMap[dep.name];
if(index !== undefined && !loadedCells[index]){
loadedCells[index] = dep;
if(++loadedCount == cellsToLoad.length){
var cbArgs = loadedCells;
loadedCells = null;
cellLoadCallback.apply(null,cbArgs);
}
}
}
}
}
};
};
cellsToLoad.forEach(function(cellName){
_this.load(cellName, require.s.ctxName,loadCb);
});
Expand Down
33 changes: 17 additions & 16 deletions dist/current/cell.js
Expand Up @@ -808,25 +808,26 @@ require.def('cell/cell-require-plugin',
if(!cellsToLoad.every(isString)){
throwError('cell/cell-require-plugin.load(): only accepts string or array of cell names');
}
var cellsToLoadMap = {};
var loadedCells = [];
cellsToLoad.forEach(function(c,i){
cellsToLoadMap[c] = i;
});
var loadCb = function(dep,e){
if(loadedCells !== null){
if(e){
loadedCells = null;
}else{
loadedCells[cellsToLoadMap[dep.name]] = dep;
if(loadedCells.length == cellsToLoad.length){
var cbArgs = loadedCells;
var cellsToLoadMap = cellsToLoad.reduce(function(r,c,i){r[c]=i; return r;},{}),
loadedCount = 0,
loadedCells = [],
loadCb = function(dep,e){
if(loadedCells !== null){
if(e){
loadedCells = null;
cellLoadCallback.apply(null,cbArgs);
}else{
var index = cellsToLoadMap[dep.name];
if(index !== undefined && !loadedCells[index]){
loadedCells[index] = dep;
if(++loadedCount == cellsToLoad.length){
var cbArgs = loadedCells;
loadedCells = null;
cellLoadCallback.apply(null,cbArgs);
}
}
}
}
}
};
};
cellsToLoad.forEach(function(cellName){
_this.load(cellName, require.s.ctxName,loadCb);
});
Expand Down
33 changes: 17 additions & 16 deletions src/cell/cell-require-plugin.js
Expand Up @@ -99,25 +99,26 @@ require.def('cell/cell-require-plugin',
if(!cellsToLoad.every(isString)){
throwError('cell/cell-require-plugin.load(): only accepts string or array of cell names');
}
var cellsToLoadMap = {};
var loadedCells = [];
cellsToLoad.forEach(function(c,i){
cellsToLoadMap[c] = i;
});
var loadCb = function(dep,e){
if(loadedCells !== null){
if(e){
loadedCells = null;
}else{
loadedCells[cellsToLoadMap[dep.name]] = dep;
if(loadedCells.length == cellsToLoad.length){
var cbArgs = loadedCells;
var cellsToLoadMap = cellsToLoad.reduce(function(r,c,i){r[c]=i; return r;},{}),
loadedCount = 0,
loadedCells = [],
loadCb = function(dep,e){
if(loadedCells !== null){
if(e){
loadedCells = null;
cellLoadCallback.apply(null,cbArgs);
}else{
var index = cellsToLoadMap[dep.name];
if(index !== undefined && !loadedCells[index]){
loadedCells[index] = dep;
if(++loadedCount == cellsToLoad.length){
var cbArgs = loadedCells;
loadedCells = null;
cellLoadCallback.apply(null,cbArgs);
}
}
}
}
}
};
};
cellsToLoad.forEach(function(cellName){
_this.load(cellName, require.s.ctxName,loadCb);
});
Expand Down

0 comments on commit 3bbb058

Please sign in to comment.