What is the best way to perform an initial RPC call at startup with GWT?
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)
thanks
thanks to @Steve-J's response, I found a solution...
Basically the idea is the following:
- create a new StartupCompleted event
- start the initial RPC call in the onModuleLoad()
- in the onSucess method of that RPC call, fire a StartupCompleted event
- 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
- register a handler for the new StartupCompleted event on the eventbus
- 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
et voila...
The initial RPC call is completed before doing anything else...
Is there anything wrong with that approach?
Note that as suggested by @Tom-Miette it is nice have a simple "loading..." message until the StartupCompleted event is received.