With Dojo gone, some questions on 4.25 and ES modules

540
2
Jump to solution
11-30-2022 01:30 PM
DanielWebb
Occasional Contributor

I’ve been playing with ES Modules in the ArcGIS API for JavaScript 4.25. Dojo is gone, so I have some questions.

  1. Is there an equivalent for “dojo/text!./somehtml.html”?
  2. Is there an equivalent for dojoConfig = {cacheBust: true}? It’s very helpful to always get fresh resources so that users get code changes right away without needing to clear their cache. Is there a way to cacheBust ES modules?
  3. Is there an equivalent for “connect.disconnect”? I used this to disconnect any tools that needed to click the map. Is there a way in 4.25 to disconnect the view.hitTest?

The more I work with ES modules, I may have more questions. But these are three so far.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
AndyGup
Esri Regular Contributor

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.

View solution in original post

2 Replies
AndyGup
Esri Regular Contributor

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.

DanielWebb
Occasional Contributor

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.

0 Kudos