Skip to content

Commit

Permalink
feat(plugins): enable loading after bootstrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 21, 2015
1 parent b5c588b commit 790c9da
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class Plugins {
constructor(aurelia){
this.aurelia = aurelia;
this.info = [];
this.processed = false;
}

/**
Expand All @@ -50,7 +51,14 @@ export class Plugins {
* @return {Plugins} Returns the current Plugins instance.
*/
plugin(moduleId, config){
this.info.push({moduleId:moduleId, config:config});
var plugin = {moduleId:moduleId, config:config || {}};

if(this.processed){
loadPlugin(this.aurelia, this.aurelia.loader, plugin);
}else{
this.info.push(plugin);
}

return this;
}

Expand Down Expand Up @@ -87,11 +95,16 @@ export class Plugins {
info = this.info,
current;

if(this.processed){
return;
}

var next = function(){
if(current = info.shift()){
return loadPlugin(aurelia, loader, current).then(next);
}

this.processed = true;
return Promise.resolve();
}

Expand Down

0 comments on commit 790c9da

Please sign in to comment.