Asynchronous call in postCreate

627
3
Jump to solution
12-10-2018 08:46 AM
JaysonLindahl
Occasional Contributor

I have a widget that needs to get information from a geoprocessing service on creation in order to populate a table.  Even though I've setup the geoprocessing service to be synchronous, it seems like the code is behaving as if it were asynchronous (at least the postCreate/startup/onOpen functions).

What I'm doing: (not sure how to make it look like formatted code, but here I go.)

postCreate: function (){

   this.inherited(arguments);

   myGPfunction();

   followupFunction();

},

startup: function(){

   this.inherited(arguments);

},

onOpen: function(){

   //do something

},

I can get the followupFunction() to wait for myGPfunction() (I've figured out how to incorporate the .then).

My problem is when I click to launch to widget in my map, postCreate,startup,onOpen all fire off.  I see in the console that PanelManager & WidgetManager say my widget have been created, then I see my results from the myGPfunction after that.

How do I get things to wait until I receive my data before continuing with creation?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jayson,

   You do not have control of the widget life cycle events and delaying their execution. You need to re-examine your work flow and adjust.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Jayson,

   You do not have control of the widget life cycle events and delaying their execution. You need to re-examine your work flow and adjust.

0 Kudos
JaysonLindahl
Occasional Contributor

I was afraid of that.  I assume the startup and onOpen functions operate in the same manner?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Correct

0 Kudos