Skip to Content
0

Multiple OData service call

Aug 22, 2017 at 05:10 AM

75

avatar image

Hi Guys,

In my application I have multiple tabs each tab using different Back-end service.

My question here is about performance improvement.

As per my understanding there can be two scenarios, either

1 - I should load all service's metadata at the time of initialization - In this case application is taking time for first load.

2 - call each service when that particular tab is getting pressed - In this case If the users is clicking second time on tab then unnecessarily I need to call service and metadata will get load.

So, how to handle this kind of scenario, how we can achieve maximum performance and minimum back-end calls.

thanks.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sharath M G Aug 22, 2017 at 08:07 AM
1

Firstly, try to have single oData service with multiple entities. Redesign the services, if necessary.

If multiple services are there, try to call first two tab services(or your preferred choice of services) in the init. Make use of component-preload to fasten the screen load.

Avoid calling service every time the tab is clicked.

Regards,

Sharath

Share
10 |10000 characters needed characters left characters exceeded
Irfan Gokak Aug 22, 2017 at 02:56 PM
0

Hi Bhuvnesh,

1. Use a batch call at init only as given below. In a single call it will load the data for all the tabs.

var batchUrls = [];
batchUrls.push( oModel.createBatchOperation( "/EntitySet1", "GET"));  
batchUrls.push( oModel.createBatchOperation("/EntitySet2", "GET"));
batchUrls.push( oModel.createBatchOperation("/EntitySet3", "GET"));
oModel.addBatchReadOperations(batchUrls);
oModel.submitBatch(function(oData, oResponse) {
    var batchError="";
    for (var i = 0 ; i<oData.__batchResponses.length ; i++){
       if(oData.__batchResponses[i].message !=null && oData.__batchResponses[i].statusCode!="200"){
             batchError='X';
             break;
        }
    }
    if(batchError !='X'){
    // Your binding goes here 
    }
}, function(oData, oResponse){
    debugger;
});

Hope this will help.

Regards,

Irfan G.

Share
10 |10000 characters needed characters left characters exceeded