I'm creating an lwc, and I've been using an imperative call to get data, where it's easy to include setting a property isLoading before the call, so that a spinner shows while it's getting the data.

    this.isLoading = true;
    getResponseMap ({
        campaignId: this.selectedCampaign,
        ... etc.

I'm cleaning up my code and I'd like to convert this imperative call to an @wire method, but I can't figure out where to put the isLoading line. If I put it after the call, I'm thinking it won't activate the spinner until the server has returned the result. Right?

Do I have to set isLoading in outside this method, like in a connectedCallback handler? That kills what I'm trying to do to clean up the code.

2 Answers 2


I recommend wiring to a property and using a getter to determine if no error or data has been provisioned.

@wire(getResponseMap, {...}) wiredProperty;

get isLoading() {
  return !this.wiredProperty.data && !this.wiredProperty.error;

You can put it in the setter function of the reactive variable bound to the wire.

You'll have to excuse the brevity, I'm on mobile and will edit my answer later with an example if you need clarity.

  • Hi, can you please update your answer Commented Jan 5, 2021 at 10:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .