It is possible to dynamically decide which models to require()?
It takes a while to load a bunch of widgets, using the JavaScript require() function, so I want to be able to only include the ones I'm using in any given instance to the ones I'm using.
Currently, I do this:
Solved! Go to Solution.
Have you considered loading the modules only when you need them? In her blog posting about code snippets, Raluca Nicola uses this syntax:
const view = require("esri/views/View").views.getItemAt(0);
Came up with a solution. Not as elegant as one would like (i.e. having to spec the class names directly), but it works.
var reqs="esri/Map", "esri/WebMap", ... "esri/widgets/Legend";
require(app.reqs, function()
var Map, WebMap, MapView, SceneView, KMLLayer, ... Legend;
for (i=0;i<app.reqs.length;++i) {
key=app.reqs[i].match(/([^\/]+)$/i)[1];
if (key == "Map") Map=arguments[i];
else if (key == "WebMap") WebMap=arguments[i];
...
else if (key == "Legend") Legend=arguments[i];
}
Have you considered loading the modules only when you need them? In her blog posting about code snippets, Raluca Nicola uses this syntax:
const view = require("esri/views/View").views.getItemAt(0);