title: Automatic 'loading' indicator when calling an async function
body: <p>I am looking for a way to automate showing and hiding a 'loading' message when calling an async service, so instead of doing this:</p>
  
  <pre><code>showLoadingWidget();
  
  service.getShapes(dbName, new AsyncCallback() {
    public void onSuccess(Shape[] result) {
      hideLoadingWidget();
      // more here...
    }
  
    public void onFailure(Throwable caught) {
      hideLoadingWidget();
    //more here
    }
  });
  </code></pre>
  
  <p>I'd like to do just this, but still show and hide the message at completion.</p>
  
  <pre><code>// this should be gone: showLoadingWidget();
  service.getShapes(dbName, new AsyncCallback() {
      public void onSuccess(Shape[] result) {
          // this should be gone: hideLoadingWidget();
          // more here...
      }
      public void onFailure(Throwable caught) {
          //this should be gone:  hideLoadingWidget();
          //more here
      }
  });
  </code></pre>
  
  <p>In short I would like to change the behavior of the async calls. Thank you for all the possible suggestions.</p>
  
  <p>Daniel</p>