title: Waiting for API call without using async await. Need to maintain a user initiated execution context after the call completes
body: <p>I'm seriously stuck here, i'm setting up ApplePay that requires a user initiated event to create an AppleSession, but i need to do a series of API calls before that happens, unfortunately due to business rules they can only happen once the user hits checkout.</p>
  <p>So the flow is checkout method gets called, in that method we do an await as the process action gets called, then provided it is successful we initialize ApplePay. Looks something like this.</p>
  <pre><code>checkout( event ) {
      await this.processPayments();
      this.checkoutAP();
  }
  </code></pre>
  <p>This fails with an error from ApplePay that it needs a user initiated event to create an ApplePaySession. The await returns a promise and wraps any code following it in it's .then. So the call to checkoutAP no longer has a user initiated event in it's stack/context. So it fails.</p>
  <p>I tried using a setInterval and check the state value, it will be updated once the process call is done. The code doesn't wait for a setInterval unless you wrap it in a promise, which brings me back to the same issue.</p>
  <p>This is my current hacky mess that doesn't work.</p>
  <pre><code>    await this.processAmenityPayments(this.getPaymentList()).then(( result ) =&gt; {
        this.paymentsProcessStatus = PAYMENTS_PROCESS_STATUS_COMPLETE;
      }, ( error ) =&gt; {
        this.paymentsProcessStatus = PAYMENTS_PROCESS_STATUS_ERROR;
        this.errors.push(error);
      });
  
      let intervalCount = 0;
      const interval = setInterval(()=&gt; {
        if( this.paymentsProcessStatus === PAYMENTS_PROCESS_STATUS_COMPLETE || this.paymentsProcessStatus === PAYMENTS_PROCESS_STATUS_ERROR) {
          clearInterval(interval);
          // I can't put it here, it's a different context and fails. 
        }
        intervalCount++;
        if( intervalCount &gt; 20 ) {
          clearInterval(interval);
          return null;
        }
      }, 1000 );
  
      // my hope is i can wait for the mess to run above, once the state has been updated then 
      // allow the code to continue at this point. 
      this.continueCheckout();
  </code></pre>
  <p>Any ideas, no matter how hacky would be most welcome.</p>
  <p>Thanks Guys!</p>