The help page at Communication between widgets—Web AppBuilder for ArcGIS | ArcGIS is pretty sparse:
As the requirement of reading or sending data between widgets is common, the BaseWidget class supports this programming model.
In the constructor of the BaseWidget class, it subscribes the publishData, dataFetched, and noData events. Meanwhile, the BaseWidget class provides the publishData and fetchData methods.
If you want the widget to publish data, call the publishData method. If you want the widget to receive data from another widget, call the fetchData method, and write code to override the onReceiveData and onNoData methods to read data.
Are there any examples showing how to pass information from one widget to another? Is there an example of how to use publishData and fetchData?
The post at Web Appbuilder Communication Between Widgets hints at it, but doesn't show enough code for me to get it working.
Thanks
Last time I tried the publishData and fetchData functions, they didn't work. You can use the Dojo topic.publish and topic.subscribe classes instead, I've had no problem using them for inter-widget communications.
Larry
Hello ! This way seems to be really interesting in my point of view ! Can you tell me more about this please ? (I'm a newbie with Dojo...)
Florian,
Not sure what else to add. As I mentioned there in the stemapp/widget/samplewidgets/WidgetCommunicarion folder there is a WidgetA and WidgetB folder that comtains code examples of how to communicate between widget A and widget B. Or you can use my response to your other thread here: Re: Sharing a variable between Widgets
Oh sorry Robert, my question was for Larry and the Dojo clue ! I'm actually trying your answer on the other thread and it seem to be really interesting too but my goal is to have several tools to use !
Excuse me again
Florian,
OK, I am sorry I did not notice you replied to Larrys post.
In that case here is the dojo doc link about topic subscribe & publish:
Thank you and no problem !
Stephen,
In the Web AppBuilder 1.1 version there is a an example of widget communication in the client\stemapp\widgets\samplewidgets\WidgetCommunication folder.