import getWorkListgetData from '@salesforce/apex/getAsyncController.getData'; isLoading = true; data = []; program = null; filter = null; @wire(getData) wiredMethod({error, data}){ getData({program:this.program,filter:this.filter}) .then(data => { this.data = data this.error = null; this.isLoading = false: }) .catch(error => { this.data = null; this.error = error; }); } handleTabChange(event) { this.isLoading = true; this.activetabContent = event.target.value; this.callAsync(); } callAsync() { getData({program: this.program,filter: this.filter}) .then(data => { this.data = data this.error = null; this.isLoading = false: }) .catch(error => { this.data = null; this.error = error; }); }
public with sharing class getAsyncController { @AuraEnabled(cacheable = true) public static List < StringProgram__c > getData(String program, String filter) { if (filter == null) return [SELECT Id FROM Program__c WHERE Name =: program]; else return [SELECT Id FROM Program__C WHERE Name =: program AND Status__c =: filter] } }