<?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 dojo topic pub/sub in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843702#M9637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To support my custom workflow I have made small change jimu.js/LayoutManager.js. The change that I have made is creating an object that I then publish within this file as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;topic.publish("channel_id","object with attributes i need to pass to widget");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a custom widget in my application that I would like to subscribe to the channel specified above when the user launches the widget to use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have tried this in the startup method of my custom widget&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;topic.subscribe("channel_id",function (e){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;alert(JSON.stringify(e));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My custom widget does seem to be able to subscribe to the channel published from LayoutManager.js. Is this possible? Is there any other way I can achieve this? Any pointers will be gratefully received.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Mar 2017 11:47:39 GMT</pubDate>
    <dc:creator>wadsonmakari</dc:creator>
    <dc:date>2017-03-30T11:47:39Z</dc:date>
    <item>
      <title>dojo topic pub/sub</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843702#M9637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To support my custom workflow I have made small change jimu.js/LayoutManager.js. The change that I have made is creating an object that I then publish within this file as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;topic.publish("channel_id","object with attributes i need to pass to widget");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a custom widget in my application that I would like to subscribe to the channel specified above when the user launches the widget to use it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have tried this in the startup method of my custom widget&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;topic.subscribe("channel_id",function (e){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;alert(JSON.stringify(e));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My custom widget does seem to be able to subscribe to the channel published from LayoutManager.js. Is this possible? Is there any other way I can achieve this? Any pointers will be gratefully received.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 11:47:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843702#M9637</guid>
      <dc:creator>wadsonmakari</dc:creator>
      <dc:date>2017-03-30T11:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: dojo topic pub/sub</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843703#M9638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wadson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;The issue is that the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;LayoutManager is created and publishes the data before the widget gets created and thus the widget subscribes to the topic after it has occurred. Have the&amp;nbsp;&lt;SPAN&gt;LayoutManager subscribe to a "my widget is started" topic&amp;nbsp;and the widget still subscribe to the "channel_id"&amp;nbsp;in its startup event and publish the "my widget is started" topic and the&amp;nbsp;LayoutManager subscribe to &lt;SPAN style="background-color: #ffffff;"&gt;a "my widget is started" topic would publish&amp;nbsp;the "&lt;SPAN&gt;channel_id" topic.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;SPAN&gt;I think a much cleaner and better route would be to use the global window._layoutManager to get to variable that you want to pass to your widget though. In the LayoutManager it sets the&amp;nbsp;window.&lt;SPAN style="background-color: #ffffff;"&gt;_layoutManager var to an instance of it self and if you create a public var in the&amp;nbsp;LayoutManager and then have your widget just use&amp;nbsp;window.&lt;SPAN style="background-color: #ffffff;"&gt;_layoutManager.yourPublicVar in its startup function.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 12:54:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843703#M9638</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-03-30T12:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: dojo topic pub/sub</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843704#M9639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much Robert, I have with a window variable as you suggested above and it has worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Apr 2017 10:17:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/dojo-topic-pub-sub/m-p/843704#M9639</guid>
      <dc:creator>wadsonmakari</dc:creator>
      <dc:date>2017-04-03T10:17:56Z</dc:date>
    </item>
  </channel>
</rss>

