title: Showing a loading indicator while calling Apex in Salesforce LWC
body: <p>What is the best way to show a loading indicator while retrieving data from Apex in a Lightning Web Component?</p>
  
  <p>I have this approach:</p>
  
  <pre><code>import { LightningElement, api } from "lwc";
  import shouldShowCard from "@salesforce/apex/ApexClass.shouldShowCard";
  
  /**
   * Card component that is conditionally shown based on Apex.
   */
  export default class ConditionalCard extends LightningElement {
      @api recordId;
  
      @api isDone = false;
  
      @api shouldShow = false;
  
      connectedCallback() {
          shouldShowCard({ id: this.recordId })
              .then(result =&gt; {
                  this.shouldShow = result;
              })
              .finally(() =&gt; {
                  this.isDone = true;
              });
      }
  }
  </code></pre>
  
  <p>And this HTML</p>
  
  <pre><code>&lt;template&gt;
    &lt;template if:false={isDone}&gt;
      &lt;div&gt;Loading...&lt;/div&gt;
    &lt;/template&gt;
    &lt;template if:true={shouldShow&gt;
      &lt;div&gt;Card&lt;/div&gt;
    &lt;/template&gt;
  &lt;/template&gt;
  </code></pre>
  
  <p>Now, this works but I'm using the LWC ESLint rules, and when I do this, I get an error/warning "no-api-reassignment" because I'm assigning the api properties in my connectedCallback.
  <a href="https://github.com/salesforce/eslint-plugin-lwc/blob/master/docs/rules/no-api-reassignments.md" rel="nofollow noreferrer">https://github.com/salesforce/eslint-plugin-lwc/blob/master/docs/rules/no-api-reassignments.md</a></p>
  
  <p>Which seems reasonable, though it very similar to the pattern that the Salesforce Lightning Spinner shows.
  <a href="https://developer.salesforce.com/docs/component-library/bundle/lightning-spinner/documentation" rel="nofollow noreferrer">https://developer.salesforce.com/docs/component-library/bundle/lightning-spinner/documentation</a></p>
  
  <p>So I'm just looking for advice on the best way to handle this or if I should just disable the ESLint rule. Other things to consider are how to test this stuff, the reactivity with the API decorator has made things pretty easy on my end but I don't want to continue if I'm not using the best approach.</p>