GithubHelp home page GithubHelp logo

Comments (5)

tomwayson avatar tomwayson commented on May 23, 2024 1

Also, I'm fairly certain that this line:

callback(new Error('The ArcGIS API for JavaScript is already loaded.'));

Needs to be guarded with an if (callback) check like we do here:

if (callback) {
// let the caller know that the API has been successfully loaded
// and as a convenience, return the require function
// in case they want to use it directly
callback(null, dojoRequire);
}

from esri-loader.

tomwayson avatar tomwayson commented on May 23, 2024 1

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).

from esri-loader.

tomwayson avatar tomwayson commented on May 23, 2024

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.

from esri-loader.

tomwayson avatar tomwayson commented on May 23, 2024

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 getScript().

from esri-loader.

tomwayson avatar tomwayson commented on May 23, 2024

I've implemented the above logic in ember-esri-loader to solve the problems I was having there:

https://github.com/Esri/ember-esri-loader/blob/d4b9d2ac209dea2d9db3be98e817ecb21df92e7f/addon/services/esri-loader.js#L42-L66

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 script.onload = () => {} to using addEventListenter when we do.

from esri-loader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.