A while back I wrote a function with a deferred object that has been working successfully for several months.
This morning, it fails and I am not sure why.
I am using the 3.11 ESRI Javascript Library:
Here is the function call with the deferred object (it is in a helper class, so it can be called over mulitple pages):
addTract: function () {
var d = new Deferred();
var layer = new FeatureLayer(tractFeatureurl, { mode: FeatureLayer.MODE_ONDEMAND, outFields: ["*"] });
layer.setDefinitionExpression("tract_id = " + this.tractid);
this.mapObj.map.addLayer(layer);
this.tracts = layer;
var q = new Query();
q.returnGeometry = true;
q.outFields = ["*"];
var cb = layer.queryFeatures(q);
cb.then(lang.hitch(this, function (results) {
this.tractFeature = results.features[0];
console.debug(this.tractFeature);
this.mapObj.zoomToFeatures(results.features);
d.resolve(this.tractFeature);
return d.promise;
}));
}
It is being class on a page like this:
var res = utils.addTract();
console.debug(res);
if (res == undefined) {
alert("undefined");
return;
}
res.then(function (tract) {
// do more processing....
});
Up until this morning, it was working fine, but now the response back from the addTract function is undefined.
The following line should be outside if the async 'then' function.
return d.promise;
John