Using promises as popupTemplate content

956
2
Jump to solution
04-30-2018 03:42 AM
KevinHaeni
New Contributor III

According to the documentation, it should be possible to use promises with popupTemplates:

const template = {

  title: 'Title',

  content: new Promise(function(res, rej) { res('test');}),
};


var featureLayer = new FeatureLayer({
   url: url,
   popupTemplate: template
});

However, with 4.7 this results in the following error:

Uncaught (in promise) TypeError: a.isFulfilled is not a function
at Object.get (MapView.js:143)

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ToddAtkins
Occasional Contributor

I've run into this problem as well after updating to 4.7. In prior versions of 4.x, native promises worked as expected for popup templates but at 4.7 they do not.

The solution is to NOT use native promises and instead use Dojo's version of promises: dojo/Deferred

The issue is that there is no .isFulfilled() method on native promises, however that method is is present on dojo/Deferred. I meant to file a bug report with Esri for this the other day when I found it but have not yet done so.

View solution in original post

2 Replies
ToddAtkins
Occasional Contributor

I've run into this problem as well after updating to 4.7. In prior versions of 4.x, native promises worked as expected for popup templates but at 4.7 they do not.

The solution is to NOT use native promises and instead use Dojo's version of promises: dojo/Deferred

The issue is that there is no .isFulfilled() method on native promises, however that method is is present on dojo/Deferred. I meant to file a bug report with Esri for this the other day when I found it but have not yet done so.

KevinHaeni
New Contributor III

Cool, thanks for your answer

0 Kudos