Skip to Content
0
May 28, 2016 at 11:30 AM

Define several OData models asynchronously

427 Views

Hello,

I try to define several OData model asynchronously.

Here how I define them (all OData models declarations are grouped in a separate function):

var oODataModel = new sap.ui.model.odata.ODataModel(
  "url1", {
  loadMetadataAsync: true
  }).attachMetadataLoaded(function(){
  that.getView().setModel(oODataModel, "model1_odata");
  });

oODataModel = new sap.ui.model.odata.ODataModel( "url2", { loadMetadataAsync: true }).attachMetadataLoaded(function(){ that.getView().setModel(oODataModel, "model2_odata"); });


and so on.


The problem is that further in code I need to call to those "modelX_odata" models and do reads, while the models are still not set (async calls are still in progress).


Is there a way to wait for all those models are complete calls and are set?


Thank you,

Yuri