<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Different widget initialisation API 4.16 vs 4.15? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/different-widget-initialisation-api-4-16-vs-4-15/m-p/384887#M35595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am in the process of updating our apps from API 4.15 to the new API 4.16. After removing all amd-dependency comments and removing declared() from the widget subclassing (and some other things...), it compiles and builds fine now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I test the application I see an important difference in the widget initialisation: with 4.15 the postInitialize is executed right after the constructor has been executed (as described in de documentation). &lt;BR /&gt;&lt;BR /&gt;In the 4.16 API it looks like the postInitialize is run right before the widget is going to be rendered. This makes a huge difference if you are relying on widget properties that are initialised in de postInitialize method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;@4.15

@subclass('test.MyWidget')
class MyWidget extends declared(Widget) {
 @property()
 public customProp;
 
 constructor(params: any) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;super(params);
 }
 
 postInitialize() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;this.customProp = 'whatever';
 }
 
 render() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;return &amp;lt;div&amp;gt;`CustomProp ${this.customProp}`&amp;lt;/div&amp;gt;;
 }
}

@4.16
@subclass('test.MyWidget')
class MyWidget extends Widget {
 @property()
 public customProp;
 
 constructor(params: any) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;super(params);
 }
 
 postInitialize() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;this.customProp = 'whatever';
 }
 
 render() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;return &amp;lt;div&amp;gt;`CustomProp ${this.customProp}`&amp;lt;/div&amp;gt;;
 }
}&lt;/PRE&gt;&lt;P&gt;Then create an instance in the calling class:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const myWidget = new MyWidget({container: 'myDiv'});&lt;BR /&gt;const proppy = myWidget.customProp; &lt;BR /&gt;// 4.15: 'whatever'&lt;BR /&gt;// 4.16: undefined&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a very simple example but it's just to describe the problem. The problem becomes more obvious when you create (sub)widgets in widgets.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We make use a lot of initialisation in the postInitialize so this has lots of impact on our code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my questions are: Are we using the postInitialize in a wrong way and what is the best way to solve this problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/43956" target="_blank"&gt;Rene Rubalcava&lt;/A&gt;‌?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:24:45 GMT</pubDate>
    <dc:creator>FreddyBroring</dc:creator>
    <dc:date>2021-12-12T16:24:45Z</dc:date>
    <item>
      <title>Different widget initialisation API 4.16 vs 4.15?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/different-widget-initialisation-api-4-16-vs-4-15/m-p/384887#M35595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am in the process of updating our apps from API 4.15 to the new API 4.16. After removing all amd-dependency comments and removing declared() from the widget subclassing (and some other things...), it compiles and builds fine now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I test the application I see an important difference in the widget initialisation: with 4.15 the postInitialize is executed right after the constructor has been executed (as described in de documentation). &lt;BR /&gt;&lt;BR /&gt;In the 4.16 API it looks like the postInitialize is run right before the widget is going to be rendered. This makes a huge difference if you are relying on widget properties that are initialised in de postInitialize method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;@4.15

@subclass('test.MyWidget')
class MyWidget extends declared(Widget) {
 @property()
 public customProp;
 
 constructor(params: any) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;super(params);
 }
 
 postInitialize() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;this.customProp = 'whatever';
 }
 
 render() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;return &amp;lt;div&amp;gt;`CustomProp ${this.customProp}`&amp;lt;/div&amp;gt;;
 }
}

@4.16
@subclass('test.MyWidget')
class MyWidget extends Widget {
 @property()
 public customProp;
 
 constructor(params: any) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;super(params);
 }
 
 postInitialize() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;this.customProp = 'whatever';
 }
 
 render() {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;return &amp;lt;div&amp;gt;`CustomProp ${this.customProp}`&amp;lt;/div&amp;gt;;
 }
}&lt;/PRE&gt;&lt;P&gt;Then create an instance in the calling class:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const myWidget = new MyWidget({container: 'myDiv'});&lt;BR /&gt;const proppy = myWidget.customProp; &lt;BR /&gt;// 4.15: 'whatever'&lt;BR /&gt;// 4.16: undefined&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a very simple example but it's just to describe the problem. The problem becomes more obvious when you create (sub)widgets in widgets.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We make use a lot of initialisation in the postInitialize so this has lots of impact on our code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my questions are: Are we using the postInitialize in a wrong way and what is the best way to solve this problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/43956" target="_blank"&gt;Rene Rubalcava&lt;/A&gt;‌?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:24:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/different-widget-initialisation-api-4-16-vs-4-15/m-p/384887#M35595</guid>
      <dc:creator>FreddyBroring</dc:creator>
      <dc:date>2021-12-12T16:24:45Z</dc:date>
    </item>
  </channel>
</rss>

