ArcGIS API 4.2 for JavaScript - Custom Widgets without TypeScript

2694
6
01-31-2017 01:35 AM
deleted-user-iPdcWUgWcsoy
New Contributor III

Hello Community,

perhaps an Esri staff could help me out.

We develop a web application with the ArcGIS API 4.2 for JavaScript. There were many changes after the beta phase of 4.0 to the official release. We handled this issue with a couple of days development. After that there were a couple of changes in the update from 4.0 to 4.1. We handled that issue to. Now we updated to Version 4.2 and ran into some new problems.

We have many custom widgets wich are created with the base class "esri/widgets/Widget" (function "createSubclass") in the typical "amd-define-style". With the use of "esri/widgets/Widget" and the new possibilty of writing custom widgets with TypeScript, it seems to be a problem. After we change all the custom modules and use the base class "esri/widgets/Widgette", no error occured and our application works fine again.

So my important question is, is this base class "esri/widgets/Widgette" save for updates and can we use it in future?

A questions beside. Is there a main plan to support only custom widgets developed with TypeScript? No "amd-define-style" anymore?

Regards

Martin

6 Replies
deleted-user-iPdcWUgWcsoy
New Contributor III

Hello again,

could anybody share it with an Esri staff? I appreciate any help! This is really important for us and planning with the ArcGIS API 4.2 for JavaScript.

Regards

Martin

0 Kudos
ReneRubalcava
Frequent Contributor

The esri/widgets/Widgette module will be removed in a future release as more out-of-the-box widgets are transitioned to our Widget framework.

We have a guide on using Accessor in both TypeScript and JavaScript. This does not apply to our Widget development due to the heavy use of JSX. You can technically write the HyperScript yourself, but it's cumbersome and not something we recommend.

It's important to note, the ViewModels of our widgets are what contains the business logic. So you can write your custom widgets in any manner you like, using a framework of your choosing, web components or plain JavaScript components.

deleted-user-iPdcWUgWcsoy
New Contributor III

Hey Rene, thanks for your reply. I hoped, that you will be the one who answer my question!

We have built our application since 4.0 was released. So we implement our widgets straight forward without TypeScript in the recommended way of ViewModels to the best of our knowledge and belief.

I will check your hint/link if we can take some advantages for our widget development and will give a reply here.

0 Kudos
deleted-user-iPdcWUgWcsoy
New Contributor III

odoe

Ok, now here is my reply.

Unfortunately there is no comfortable way to develop our widgets without TypeScript. So we have to start nearly from scratch. Doh!

So I have two questions.

1. Do you have a nice documentaion where I can find some hints to start with Widget development including Accessors/ViewModels from scratch? I'm really new to that stuff and I need to develop some widgets really soon. I read the documentation from the Esri site herehere and here. I need some more information please.

2. How many main changes will be happen in the future releases of the API? For every update we need several of days and weeks to get our application runnable again.

Thanks in advance.

Regards

Martin

0 Kudos
ReneRubalcava
Frequent Contributor

The Widget dev will be the biggest thing, that's why we didn't doc custom widget dev until now. There are going to be more changes and updates, but if we don't doc it, we don't recommend it.

In next the release, we are also adding a guide to help new users set up a TypeScript development environment.

Here is a demo app I put together that shows a Widget with a ViewModel. ViewModels are basically just extending Accessor. You could write a ViewModel without TypeScript and just implement Accessor in regular JavaScript.

GitHub - odoe/esrijs4-ts-demo 

Here is a sample widget in our Widget framework.

esrijs4-ts-demo/summary.tsx at master · odoe/esrijs4-ts-demo · GitHub 

If you are not comfortable using TypeScript for development, you don't need to use our widget framework. It doesn't provide any advantage or integration with the API in any way. It just happens to be what we use. We also need to provide the doc for other teams external to the JSAPI team that write widgets.

But I could have easily written this in regular JavaScript without our widget framework, just using a ViewModel that implements Accessor to watch for updates.

I have similar samples here in regular JavaScript.

GitHub - odoe/gen4: Sample EsriJS 4 Application from generator-arcgis-js-app 

GitHub - odoe/esrijs4-vt-palette: Demo app of using Color Palettes with Vector Tiles 

deleted-user-iPdcWUgWcsoy
New Contributor III

Great thank you! I will check your samples but I think I can take advantage of it.

We are now to deep in this thing. So we will use it like you do ;). Our plan is (and I startet that meanwhile) to use ViewModels written in JavaScript and use them in widgets written in TypeScript.

Can I contact you for some more questions or should I open new separate threads?

0 Kudos