I think that you can wire a function rather than a var as the result of fetchL2PropertyValues
.
This means it's basically a callback where you can set values and run your other logic.
So you'd write it like:
@wire(fetchL2ProductValues,{productId: '$l1SavedValue',userType: '$userType'})
l2ProductValuesCallback({ error, data }) {
if (data) {
//do all the logic you wanted to run in the callback...
var key,count =0;
for(key in this.l2ProductList){
if(this.l2ProductList.hasOwnProperty(key)){
count++;
}
}
if(count > 0){
this.showProductL2 = true;
}else{
this.showProductL2 = false;
}
} else if (error) {
//handle your error
}
}
Also... that logic seems like it could be simplified - try investigating array.some()
which iterates until a condition evaluates to true. Depends on the data structure of your list that you are returning.