Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Easy to use service wrapper around esri-loader? #124

@nickcam

Description

@nickcam

Hi Guys, not really an issue...but more a request for guidance.
I'm getting around to upgrading an angular app to cli 6.x and moving away from esri-system-js.
It's basically a map and some menus and has heaps of esri dependencies through out.

As such it would be a real pain to have to load modules using this pattern everywhere:

loadModules(['esri/views/MapView', 'esri/Map'])
.then(([MapView, Map]) => {
  // do stuff
});

Even using await it's not so nice to have scattered everywhere.
I've created a service to inject around that can encapsulate this and a list of modules I'll want to load straight away or lazily. They're in this gist - https://gist.github.com/nickcam/162f3a375206737e5b5e42fc638c0fd8

This will allow creating a new arcgis object like so where the service is injected:
let map = new this.esri.Map({ //whatever params// });

To lazy load:

await this.esri.load(["SimpleMarkerSymbol"]);
let sms = new this.esri.SimpleMarkerSymbol();

This seems ok-ish, the overhead is adding every module to the modules list and creating a property on the service for each module (for typings and ease of calling).

I can't help but feel it's a bit shit though...so before I crack on and rewrite a bunch of stuff wanted to check if you have any better ideas??
I have checked out the other issues in this repo - particularly this one, #71, which I think is similar, but not quite as succinct as I would have hoped.

Also any examples of using typescript 2.9 import() yet?
Thanks heaps!

Metadata

Metadata

Assignees

No one assigned

    Labels

    FAQFrequently asked questions

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions