Select to view content in your preferred language

how to check view is created or not before executing any other operation

629
1
02-02-2021 10:53 PM
RitikaManderwal
Emerging Contributor

i have created two function as follows:

1. to create basemap and view

2. to add sketch widget or some other widgets to it

i am calling both the function from a separate js file in order as follows:

loadbasemap();

addwidget()

the problem is before completely executing loadbasemap().it try executing addwidget() and throwing error that "view not created".

what could be the reson or how to handle it.

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

I've found the video that @ReneRubalcava made to be helpful in determining when things are ready to be used: https://www.youtube.com/watch?v=fUz1IGh0sb8&feature=emb_title

It is a little out of date, with "when" replacing "then". He has a newer version of it here, geared towards showing when a layer is ready.

Another thing to look at is calling the addwidget function from within the loadbasemap function when the view is ready.