B2G/gecko/services/common/async.js
/**
   * Create a sync callback that remembers state, in particular whether it has
   * been called.
   */
Create a sync callback that remembers state, in particular whether it has
been called.
Create a sync callback that remembers state in particular whether it has been called .
function makeSyncCallback() {
    let onComplete = function onComplete(data) {
      onComplete.state = CB_COMPLETE;
      onComplete.value = data;
    };
    onComplete.state = CB_READY;
    onComplete.value = null;
    onComplete.throw = function onComplete_throw(data) {
      onComplete.state = CB_FAIL;
      onComplete.value = data;
      throw data;
    };
    return onComplete;
  }
function makeSyncCallback ( ) { let onComplete = function onComplete ( data ) { onComplete . state = CB_COMPLETE ; onComplete . value = data ; } ; onComplete . state = CB_READY ; onComplete . value = null ; onComplete . throw = function onComplete_throw ( data ) { onComplete . state = CB_FAIL ; onComplete . value = data ; throw data ; } ; return onComplete ; }
Create a sync callback that remembers state, in particular whether it has
 been called.
Create a sync callback that remembers state in particular whether it has been called .
// The main callback remembers the value it was passed, and that it got data. // Initialize private callback data in preparation for being called. // Allow an alternate callback to trigger an exception to be thrown. // Cause the caller to get an exception and stop execution.