Skip to content

Commit

Permalink
refine loadSubpackage (cocos#2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
2youyou2 authored and jareguo committed Jun 29, 2018
1 parent 1d30cf8 commit 48496e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cocos2d/core/load-pipeline/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,17 @@ Downloader.prototype.handle = function (item, callback) {
Downloader.prototype.loadSubpackage = function (name, completeCallback) {
let pac = this._subpackages[name];
if (pac) {
downloadScript({url: pac.path}, completeCallback);
if (pac.loaded) {
if (completeCallback) completeCallback();
}
else {
downloadScript({url: pac.path}, function (err) {
if (!err) {
pac.loaded = true;
}
if (completeCallback) completeCallback(err);
});
}
}
else if (completeCallback) {
completeCallback(new Error(`Can't find subpackage ${name}`));
Expand Down

0 comments on commit 48496e6

Please sign in to comment.