Closed ecj2 closed 6 years ago
Adding success and failure callbacks to loading methods would be a good idea. It might also be worthwhile to add a method to shutdown Momo (to remove all timeout procedures) in the event of errors.
Better yet, use a promise to return resources when successful, or false if met with failure. Then use await
in an async
function to synchronously load resources and check for errors.
Example:
let bitmap = undefined;
async function loadResources() {
bitmap = await Momo.loadBitmap("example.png");
if (!bitmap) {
// Do error handling here...
}
}
Due to the asynchronous nature of JavaScript, it is impossible to sequentially and immediately check for errors when loading resources. Even so, it would be useful to add an asynchronous method to at least be able to acknowledge errors later on, even if nothing can be done to fix them.
Types of errors to look for:
* Samples can already be checked to see if the browser supports a given format, but nothing beyond that.