title: GWT : best way to do an initial RPC call at startup?
body: <p>What is the best way to perform an initial RPC call at startup with GWT?</p>
  
  <p>I would like to retrieve configuration data that are dynamically generated on the server side, when a user loads a page. but If I do an asynchronous RPC call from the browser to retrieve the data, I sometimes don't get a response before the page is fully loaded, resulting in the page not having access to that configuration data. (no Thread.sleep() function for example)</p>
  
  <p>thanks</p>
  
  <hr>
  
  <p>thanks to @Steve-J's response, I found a solution...</p>
  
  <p>Basically the idea is the following:</p>
  
  <ul>
  <li>create a new StartupCompleted event</li>
  <li>start the initial RPC call in the onModuleLoad()</li>
  <li>in the onSucess method of that RPC call, fire a StartupCompleted event</li>
  <li>at the end of the go() method of the App Controller, instead of inserting the default action in the History [ with a History.newItem("default"); ], or to fire the current History state if called through a bookmark [ with a History.fireCurrentHistoryState(); ], don't do anything</li>
  <li>register a handler for the new StartupCompleted event on the eventbus</li>
  <li>when the StartupCompleted event is fired, catch it and at that time, insert the default action in the history or fire the current history state</li>
  </ul>
  
  <p>et voila...</p>
  
  <p>The initial RPC call is completed before doing anything else... </p>
  
  <p>Is there anything wrong with that approach?</p>
  
  <p>Note that as suggested by @Tom-Miette it is nice have a simple "loading..." message until the StartupCompleted event is received.</p>