some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-03-08 20:05:49 +03:00
parent 1c29da7ee7
commit 59dc0d01c5
2 changed files with 35 additions and 24 deletions

View File

@ -571,6 +571,9 @@ var FileSystemLoaderActions = actions.Actions({
method: 'loadImages', method: 'loadImages',
} }
}) })
.then(function(){
delete that.changes
})
}) })
}], }],

View File

@ -54,31 +54,39 @@ var RecoverActions = actions.Actions({
// parent actions at this point... // parent actions at this point...
loadOrRecover: ['- Location/', loadOrRecover: ['- Location/',
function(data){ function(data){
var that = this
return new Promise(function(resolve, reject){
// this is the critical section, after this point we // this is the critical section, after this point we
// are doing the actual loading.... // are doing the actual loading....
try { try {
this.load(data) that.load(data)
resolve(data)
// something bad happened, clear and handle it... // something bad happened, clear and handle it...
} catch(err){ } catch(err){
this.clear() that.clear()
console.error(err) console.error(err)
// recover to last location... // recover to last location...
if(this.__recover){ if(that.__recover){
this.recover() that.recover()
reject('recovered')
// fail... // fail...
} else { } else {
// clear the recovery data... // clear the recovery data...
delete this.__recover delete that.__recover
// fail... // fail...
throw err //throw err
reject(err)
} }
} }
})
}], }],
// Recover from load error... // Recover from load error...