-
Notifications
You must be signed in to change notification settings - Fork 79
only return an error when trying to load a different version of the JSAPI #28
Comments
Also, I'm fairly certain that this line: esri-loader/src/esri-loader.ts Line 34 in ff9989b
Needs to be guarded with an esri-loader/src/esri-loader.ts Lines 52 to 57 in ff9989b
|
Above I suggest checking whether "the user is trying to load a different version of the JSAPI." That may be tricky, b/c when they are about to load the second script (and when the first script is still loading), all you have have is the URL, which may not be deterministic. As a first pass, I'd say it would be sufficient to check if the user is trying to load the exact same script (i.e. same URL). Later we can refine by trying to parse the version out of the URL and if that's successful, check whether or not the user is trying to load the same version. |
Also, whenever we return an error b/c a script is already loading/ed, we should also pass that script as the second argument to the callback as a convenience to the caller (I know that would be helpful to me right now as I'm working through how to handle the above errors in ember-esri-loader). |
Ignore that last comment. I think that would be akward w/ the current boostrap() API: esriLoader.bootstrap((err, dojoRequireOrScriptTagDependingOnWhetherOrNotThereWasAnError) => {...}, options); A better way to achieve similar would be to export |
I've implemented the above logic in ember-esri-loader to solve the problems I was having there: I'd like to move all that logic into this library as the resolution to this issue. We'll probably want to move from using |
Currently, we
throwreturn an error when the user calls bootstrap more than once, regardless of:Currently this is causing problems in ember-esri-loader tests (Esri/ember-esri-loader#27). I can work around those problems in that library, but I am wondering if it actually makes sense to return an error in all the above conditions.
I'm pretty sure we want to return an error whenever the user is trying to load a different version of the JSAPI.
If it's the same version of the JSAPI, and if the script has already loaded we should just call the callback w/
window.require
as we do here:esri-loader/src/esri-loader.ts
Lines 47 to 56 in ff9989b
If the script hasn't already loaded, I think we want to piggy back on the original
onload
call.The text was updated successfully, but these errors were encountered: