I have a lwc with multiple wires that retrieve information and I need to display a spinner while all this calls are being made and hide it whenever they finish.
I've seen that you can do this wiring the property instead of a function but when I try this my functionality is being truncated so I miss data or it's not getting retrieved when needed.
This is my lwc.js:
@wire (getTypes, { filtersJSON : '$filtersJSON' }) wireTypes ({ error, data }){
if(data) this.handleUpdateCachedOptions('Type__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
@wire (getBrands, { filtersJSON : '$filtersJSON' }) wireBrands ({ error, data }){
if(data) this.handleUpdateCachedOptions('Brands__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
@wire (getModels, { filtersJSON : '$filtersJSON' }) wireModels ({ error, data }){
if(data) this.handleUpdateCachedOptions('Model__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
@wire (getColors, { filtersJSON : '$filtersJSON' }) wireColors ({ error, data }){
if(data) this.handleUpdateCachedOptions('Color__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
@wire (getFormats, { filtersJSON : '$filtersJSON' }) wireFormats ({ error, data }){
if(data) this.handleUpdateCachedOptions('Format__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
@wire (getFinish, { filtersJSON : '$filtersJSON' }) wireFinishes ({ error, data }){
if(data) this.handleUpdateCachedOptions('Finish__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
@wire (getThickness, { filtersJSON : '$filtersJSON' }) wireThicknesses ({ error, data }){
if(data) this.handleUpdateCachedOptions('Thickness__c', (data && data.length > 1 ? data : []));
else if(error) this.handleShowErrorToast(error);
}
Is there some way to trigger this wiring the functions?
Thanks in advance!
Regards,