I am performing a javascript sorting an array of objects of size 2500 records that is displayed in lightning data table. This takes 3-5 seconds. Meanwhile I wanted to show lightning-spinner.
Html Code
<template if:true={showSpinner}>
<lightning-spinner alternative-text="Loading" size="medium" ></lightning-spinner>
</template>
Javascript code
this.showSpinner=true;
this.allData = this.sortMyData(this.allData,sortByMapped,this.sortDirection);
this.showSpinner=false;
Spinner never displays. But If I put a breakpoint in the second line , the spinner appears. I believe this happens because the time to sort is very less. But the time taken to render the records in data table takes more time. If this is correct , is there a way I can show the spinner till the complete table renders the data ? If not, what am I missing?