Bug 920337 - Use promise to ensure we don't miss project load. r=paul

This commit is contained in:
J. Ryan Stinnett 2013-09-24 21:22:08 -05:00
parent a2f5d7482a
commit 76822a147d
2 changed files with 9 additions and 4 deletions

View File

@ -88,12 +88,19 @@ const IDB = {
const store = new ObservableObject({ projects:[] });
let loadDeferred = promise.defer();
IDB.open().then(function (projects) {
store.object.projects = projects;
AppProjects.emit("ready", store.object.projects);
loadDeferred.resolve();
});
const AppProjects = {
load: function() {
return loadDeferred.promise;
},
addPackaged: function(folder) {
let project = {
type: "packaged",

View File

@ -39,10 +39,8 @@ let UI = {
this.template = new Template(document.body, AppProjects.store, Utils.l10n);
this.template.start();
AppProjects.store.on("set", (event,path,value) => {
if (path == "projects") {
AppProjects.store.object.projects.forEach(UI.validate);
}
AppProjects.load().then(() => {
AppProjects.store.object.projects.forEach(UI.validate);
});
},