So to begin with I really do love this language and everything that surrounds it. The community is great as well. I just have a question in regards to AMD import style as my established module and defined types seem to be confusing me more. So far I have:
but the problem keeps returning errors such as promise errors and types missing. I am trying to use the 3rd party esri-loader library for geospatial analysis and this is kind of a sample:
loadModules(['esri/views/MapView', 'esri/WebMap'])
.then(([MapView, WebMap]) => {
// then we load a web map from an id
var webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: 'f2e9b762544945f390ca4ac3671cfa72'
}
});
// and we show that map in a container w/ id #viewDiv
var view = new MapView({
map: webmap,
container: 'viewDiv'
});
})
.catch(err => {
// handle any errors
console.error(err);
});
And be careful with Js.Promise.then_, it has a âsubject lastâ signature, so you need to use |> pipe operator or consider using rescript-promise to have better syntax
open Js.Promise
let binder = EsriBindingTest.loadModules(["esri/Graphic"])
|>then_(...)
|>catch(...)
Thanks! It doesnât however explain why itâs deprecated. I canât see any reason why the two pipe operators shouldnât coexist. Both are useful in different situations.
Itâs deprecated because we are enforcing consistent styles for all APIs. E.g the stdlib will eventually follow the -> approach in all of its modules. We also donât want our users to choose between different pipe operators, because itâs confusing at best whenever you are hitting a pipe-last vs pipe-first based third-party package.
@ryyppy I have seemed to get it to work but the type bindings for letâs say defining an external method that does the same functionality is a bit tricky. I do have to define it as a method but it returns a promise but I do not need to define a new Promise initiator within a variable so this should work but itâs bouncing back a bit:
This binding is really busted because itâs still taking the promise value in the last argument position. Luckily we will fix this up in the next few weeks.
Yeah it still is kind of an issue. I am just doing the @arcgis/core imports instead and might come up with a custom method that fixes the AMD issue. As it is a bit difficult to correctly define it within rescript as you would with other JS methods and so on.
Can you please prepare a workable playground link with your latest code so we can help troubleshooting? Your latest output snippet shows a resolve(EsriLoader.loadModules), which looks wrong.
Also will release a library for it. Thanks again @ryyppy@yawaramin and everyone for the help also @yawaramin I did try that but I need to create an easier way to dynamically load maps and layers with specific data. Loading it this way reduces a lot of boilerplate but I think they primarily released the other way to make it easier to integrate it easier within already created applications for streamlining the integration process.