I have a widget A that publishes data and two more widgets B and C. When B calls fetchData for widget A the onReceiveData events fire for both B and C. Is that supposed to happen? I would expect only B's onReceiveData event to fire since it is the one who called fetchData.
Joe,
If you just do widget.fetchData(); the you get that result. But if you provide a widget ID in the fetchData(someWidgetId); then you can limit it.
Hmm still happens. Does it matter that C had called fetchData(someWidgetId) in the past before B calls fetchData(someWidgetId)? It seems C is now subscribed to receive data whenever a fetch is requested for A.
Joe,
In the BaseWidget.js file there is this:
//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
this.listenWidgetIds = [];
I don't think that will work for me. I would have to update listenWidgetIds property before every fetch to make sure only the caller is receiving the data. I want all my widgets to be able to get data from widget A but I only want a widget to receive the data if it is the source of the fetch call.
I'm just going to use the WidgetManager to get a reference to my A widget and then directly access properties that I set on it.
var widgets = this.appConfig.getConfigElementsByName('MyWidget');
var widgetId = widgets[0].id;
var myWidget = this.widgetManager.getWidgetById(widgetId);
// Access data of widget directly
var data = myWidget.someProperty;
// use data...