I’ve been playing with ES Modules in the ArcGIS API for JavaScript 4.25. Dojo is gone, so I have some questions.
The more I work with ES modules, I may have more questions. But these are three so far.
Thanks!
Solved! Go to Solution.
Hi @DanielWebb, good questions, they related to both the AMD and ES modules:
1. No. You can use esri/request or use native fetch directly to load HTML as a string into your app
2. This can be handled through industry-standard patterns such as using Etags. You can also set the cacheBust option in esri/request, but this is a different implementation from dojo, instead of adding a param, it tells fetch to make a conditional request. If you always want to cacheBust, then you can use a requestInterceptor with the url set to null.
3.You can remove event listeners natively. If you are using an "on" listener, you can remove those using the APIs remove() method.
Hi @DanielWebb, good questions, they related to both the AMD and ES modules:
1. No. You can use esri/request or use native fetch directly to load HTML as a string into your app
2. This can be handled through industry-standard patterns such as using Etags. You can also set the cacheBust option in esri/request, but this is a different implementation from dojo, instead of adding a param, it tells fetch to make a conditional request. If you always want to cacheBust, then you can use a requestInterceptor with the url set to null.
3.You can remove event listeners natively. If you are using an "on" listener, you can remove those using the APIs remove() method.
Thanks Andy! This is old but it’s been a big learning curve for me—including Webpack bundling—and I’m just now getting a handle on some of this (as I get time apart from normal daily work).
The native fetch works well. Thanks for that.
I couldn’t figure out Etags or the esri/request stuff. But the cacheBust seemed to be fixed with Webpack bundling. I have the output set to '[name].[contenthash].bundle.js' which looks like it gives a new alphanumeric id to the file name. That should force a cachebust.
The ‘remove’ also seems to work for onclick listening.
Thanks again for the directions to look.