I'd need a function to wait until the asynchronous task has completed and then return.
In my example, I'm getting undefined returned from the "execute" method:
var result = myClass.execute(obj); //undefined
How can I get the actual result returned?
return declare(null, {
constructor: function (obj) {
this.mapServiceUrl = obj.mapServiceUrl;
this.geometry_json = obj.geometry_json || undefined;
this.where = obj.where || "1=1";
},
execute: function () {
var queryTask = new QueryTask(this.mapServiceUrl),
query = new Query()
;
query.returnGeometry = true;
query.outFields = ["RDUWI"];
if (this.geometry_json) {
query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
query.geometry = Polygon(this.geometry_json);
};
query.where = this.where;
var deferred = queryTask.execute(query);
deferred.then(function (featureSet) {
return featureSet;
});
}
});