Skip to Content

Multiple OData service call

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Aug 22, 2017 at 08:07 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 22, 2017 at 02:56 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded