The BaseWidget class supports reading or sending data between Web AppBuilder for ArcGIS widgets. In the constructor of the BaseWidget class, the publishData, dataFetched, and noData events are subscribed. The BaseWidget class also 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.
All published data is stored in a data store called DataManager. As a result, the widget can receive published data before it is loaded. For example, widget B wants to read data from widget A. Before widget B is loaded, the data published by widget A is stored in DataManager. When widget B is loaded, it calls the fetchData method to fetch the data from DataManager. After widget B is loaded, it receives all of the published data from widget A. In some case, you may want to open another widget by this.openWidgetById method before sending the message to it. The following diagram illustrates this workflow:
See WidgetCommunication sample in \client\stemapp\widgets\samplewidgets directory of your Web AppBuilder installation.
Since version 2.1 and up, you can pass feature set between widgets. See Create a feature action in your widget for details.
The method details are described in the following table:
Publishes the data.
Fetches the data.
Fetches the data
Invoked when data is available.