Role of Dojo in javascript api

267
3
11-12-2020 12:40 PM
RobertMarros
Occasional Contributor II

It seems that in the past Dojo has been necessary for using the ArcGIS API, at least for certain functionality. Is this still true, or is it possible to do everything that one might want to without it? Are there any reasons to continue to use it, aside from the obvious ones that Dojo can provide generally, as opposed to specifically for ArcGIS?

Edit: I just saw this: "We removed Dojo’s declare module, and pretty much stopped using Dojo altogether" from https://community.esri.com/t5/arcgis-api-for-javascript-blog/bg-p/arcgis-api-for-javascript-blog. Responses are still welcome, though, if there's any nuance to that statement to know about or anything else to consider re. Dojo.

3 Replies
Noah-Sager
Esri Regular Contributor

Hi @RobertMarros, thanks for the question. The answer is two-fold: 1) it depends on what you are currently using Dojo for, and 2) you should be able to do pretty much everything without Dojo now. However, if you run into an edge case, please feel free to post here. Also interested in hearing the thoughts from other members of this community.

0 Kudos
RobertMarros
Occasional Contributor II

Hi @Noah-Sager,

Thanks for your reply. I have existing code that originally used API version 4.11. I have a require statement that includes "dojo/on" and "dojo/domReady". I changed my code to reference 4.17 and commented out the dojo references in the require statement, and not surprisingly I get fatal errors, though it's not obvious to me how they're related to dojo, given where the errors are occuring. I do have the following statement in my code, though it's not identified as the line where an error is occurring:

on(mapView, "click", executeIdentifyTask);

I tried

mapView.addEventListener("click", executeIdentifyTask);

and my code still runs, but I can no longer click on my map and get a popup with additional feature information. Everything works fine with none of the above changes, by the way.

Assuming we want to get rid of Dojo, any advice, general or specific, on doing so? It would be great if there is some sample Esri code that shows an implementation with Dojo and without it. I am pretty green when it comes to web development, as you can probably tell.

0 Kudos
RobertMarros
Occasional Contributor II

Never mind 🙂. mapView.on("click", executeIdentifyTask) worked (what didn't work is trying to format that code as inline code here--maybe it's my browser?). I also changed back to 4.11, so apparently the code I had didn't require Dojo at all, with that one minor change, as far as I can tell. (Everything seems to be working OK, but it's possible I'm missing something.) 

0 Kudos