Select to view content in your preferred language

Send ID to Geometry Service to link callback?

1222
4
Jump to solution
11-08-2014 07:07 PM
JerryGarcia
Frequent Contributor

Is it possible to send an ID to the Geometry Service so I know which callback links to the original request?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AaronHeyman
Occasional Contributor

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";

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Jerry,

   You can do an inline function on the results of the geometryService or use the "then" word like in this Sample

0 Kudos
JerryGarcia
Frequent Contributor

Thanks for your reply.

Can you provide an example of an inline function that does this?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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

      }));

0 Kudos
AaronHeyman
Occasional Contributor

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";