Esri / application-boilerplate-3x-js

Starter application that simplifies the process of building templates for the ArcGIS.com template gallery.
https://developers.arcgis.com/javascript/
Apache License 2.0
90 stars 68 forks source link

Add an "error" event for the Template class #18

Closed driskull closed 10 years ago

driskull commented 10 years ago

The Template class uses Deferreds that get resolved but when something fails there is no way to report that. My app needs to know when there was an error to stop the loading spinner and display the error. It would be nice if the Deferreds were rejected on error and a 'error' event was emitted. @kellyhutchins What do you think?

driskull commented 10 years ago

so I could do this:

var myTemplate = new Template(supportsLocalization);
            on(myTemplate, "ready", function(config) {
                //The config object contains the following properties: helper services, (optionally) 
                //i18n, appid, webmap and any custom values defined by the application. 
                //In this example we have one called theme. 
                Main(config);
            });
            on(myTemplate, "error", function(error) {
                doSomethingwith(error);
            });
driskull commented 10 years ago

Or we could change Template to return a deferred. Maybe both options.

var myTemplate = new Template(supportsLocalization).then(function(config){
   Main(config);
}, function(error){
   doSomethingwith(error)
});
kellyhutchins commented 10 years ago

@driskull sounds good. Do you have time to make the edits? Once done I could test with a few templates and make sure everything is ok.

driskull commented 10 years ago

I was thinking it would be something we could tackle after DevSummit. I'll probably take a stab at it then.

kellyhutchins commented 10 years ago

Sounds good.