How can a queryTask be executed synchronously? I'd like a feature set to be returned instead of deferred object.
Answer
In instances like this, the API returns deferred objects in case you're interested in identifying when more than one request to a server has resolved, but its not something your application logic has to worry about if you're just dealing with one task at a time.
for example, when you call QueryTask.execute() and leverage the in-built callback, you can get a reference to the featureset output you want:
queryTask.execute(query, myCallback, myErrorBack);
...
myCallback(results) {
//do something
}
To work with QueryTask deferreds, you have an additional option to do something like this:
var myDeferred = queryTask.execute(query);
myDeferred.then(...
No comments:
Post a Comment