Mapview's when() event on view giving error?

3146
2
Jump to solution
01-10-2018 03:40 AM
NisarAhmed
New Contributor

I have a view which uses a webmap instance. According to the documentation, MapView can leverage the when() function to indicate that the view is ready to be manipulated. But I'm getting  a "view.when is not a function" error in browser console.

The code I'm using is:

var webmap = new WebMap({
    portalItem: {
        id: "<some long id>"
    }
 });

var view = new MapView({
   map: webmap,
   container: "esriMap"
 });

view.when(function(){ // this line is throwing the error
    
}, function(error){
   alert(error.message);
});

I'm using ESRI Javascript v4.5 API. What am I missing here?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Nisar,

  The when was introduced in 4.6 not 4.5.

At 4.6, then() is deprecated in favor of when(). The then() method will still be honored at 4.6, but will throw warning messages in the browser developer console, to ease the process of updating apps to using when(). We made this change to allow the use of native ES6 promises within the context of the ArcGIS API for JavaScript.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Nisar,

  The when was introduced in 4.6 not 4.5.

At 4.6, then() is deprecated in favor of when(). The then() method will still be honored at 4.6, but will throw warning messages in the browser developer console, to ease the process of updating apps to using when(). We made this change to allow the use of native ES6 promises within the context of the ArcGIS API for JavaScript.

NisarAhmed
New Contributor

Oh, my bad! Don't know how I missed the version number.

0 Kudos