Andrew,
1. In the Web AppBuilder 1.3 version there is a an example of widget communication in the client\stemapp\widgets\samplewidgets\WidgetCommunication folder.
2. you can see the testing module that esri used for the datamanager by going to client\stemapp\jimu.js\tests\test-datamanager.
There is some doh/runner stuff that can get confusing but if you just focus on the publishData and fetchData stuff you can get a pretty good idea. One of the really great things is that you can have your second widget use the listenWidgetIds property and it will listen for publishData calls from your widgetA
//listenWidgetIds: String[]
// app use this property to filter data message, if not set, all message will be received.
// this property can be set in config.json
//About the communication between widgets:
// * Two widgets can communicate each other directly, or transferred by DataManager.
// * If you want to share data, please call *publishData*. the published data will
// be stored in DataManager.
// * If you want to read share data, you can override *onReceiveData* method. Whenever
// any widget publishes data, this method will be invoked. (communication directly)
// * If you want to read the data that published before your widget loaded, you can call
// *fetchData* method and get data in *onReceiveData* method. If the data contains
// history data, it will be availble in *historyData* parameter.
// (transferred by DataManager)
3. Here is some code snippet of how I am using widget communication in my widgets (using these functions it does not matter if the receiving widget is not open, because when it does open the fetchData is called, but if it is open the the onRecieveData will handle it).
//In the listening widget
startup: function(){
this.inherited(arguments);
this.fetchData();
},
onReceiveData: function(name, widgetId, data) {
if(data.message && data.message === "Deactivate_DrawTool"){
this.drawBox.deactivate();
}
},
//in the sending widget
//In one of my functions I have this called before I activate the DrawBox dijit
aspect.before(this.drawBox, "_activate", lang.hitch(this, function(){
this.publishData({message: "Deactivate_DrawTool"});
}));