Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async canLoad(
route: Route,
segments: UrlSegment[]
): Promise {
if (isLoaded()) {
return true;
}
try {
const options = this.getOptions();
// load esri script and dojoConfig;
await loadScript(options);
// add cors enabled hosts
const [config] = await loadModules(['esri/config']);
for (const server of environment.trustedServers) {
config.request.trustedServers.push(server);
}
return true;
}
catch (ex) {
console.error(ex);
return false;
}
}
loadScript (options) {
return esriLoader.loadScript(options)
.then(script => {
// have to wrap this async side effect in Ember.run() so tests don't fail
// may be able to remove this once we can have esriLoader use RSVP.Promise
run(() => {
// update the isLoaded computed property
this.notifyPropertyChange('isLoaded');
return script;
});
});
},
load(options?: ILoadScriptOptions): Promise {
this.loadScriptOptions = options ? options : {};
return loadScript(options);
}