Is it possible to send an ID to the Geometry Service so I know which callback links to the original request?
Solved! Go to Solution.
Yes you can send more information to the callback using the dojo command lang.partial.
This is a typical query task, which returns a result set:
var someVar = "Test";
listQueryDeferreds = listTask.execute(listQuery, function(results) {
// the code to process the results, someVar will be "Not Test" when this callback executes;
});
someVar = "Not Test";
Now with lang,partial
var someVar = "Test";
listQueryDeferreds = listTask.execute(listQuery, lang.partial( function(someVar, results) {
// the code to process the results. someVar will be "Test";
}, someVar ));
someVar = "Not Test";
Jerry,
You can do an inline function on the results of the geometryService or use the "then" word like in this Sample
Thanks for your reply.
Can you provide an example of an inline function that does this?
Jerry,
An inline function would simply be:
GeometryService.simplify([geoms],lang.hitch(this,function(sgeoms){
//do something with the sgeoms
//because you used lang.hitch you have access to the scope of the
//function that called this async result, which means
//you have access to variables of the function that called this
}),lang.hitch(this,function(err){
//do something
}));
Yes you can send more information to the callback using the dojo command lang.partial.
This is a typical query task, which returns a result set:
var someVar = "Test";
listQueryDeferreds = listTask.execute(listQuery, function(results) {
// the code to process the results, someVar will be "Not Test" when this callback executes;
});
someVar = "Not Test";
Now with lang,partial
var someVar = "Test";
listQueryDeferreds = listTask.execute(listQuery, lang.partial( function(someVar, results) {
// the code to process the results. someVar will be "Test";
}, someVar ));
someVar = "Not Test";