Library Initialization Walkthrough - fgpv-vpgf/geoApi GitHub Wiki
index.js
is the main starting point for loading the library. The primary goal here is to load the ESRI Javascript API objects, which are DOJO objects, then generate the API with reference to the loaded ESRI API and notify the caller when this process is complete. All other functions in geoApi depend on having these objects loaded & available.
General steps during load (all take place in index.js
unless noted)
- Load the ESRI Javascript API. This is done by injecting a script tag into the site and waiting for the onload event to fire. See the
main return Promise
- Load all the ESRI DOJO objects using the DOJO require statement. This will bring all our objects into memory / variables. See
makeDojoRequests
- Package the ESRI DOJO objects into a bundle object for use in the rest of the initializer. See
makeDojoRequests
- Generate the geoApi object. Use the bundle of ESRI DOJO objects to configure the API function calls and adds them to the result object. This is the public API that the calling application will use. See
initAll
Functions called in step 4 configure the geoApi with the ESRI API. They accept the ESRI DOJO bundle as parameter and return the real API function, the trick being the real function can see the bundle, but the bundle is hidden from a consumer of the API. TODO link to section describing this in more detail.