Reputation: 1
Can anyone give a simple code(or links) for asynchronous method calls/ parallel execution of methods in GWT.(Google Web ToolKit) My requirement in the project is to make calls to multiple methods at the same time, and these methods execute in parallel and return results to the application once completed.
The RPC's use has made the browser to pop up "irresponsive js code" warning message as the data to load is huge and takes lot of time.
Upvotes: 0
Views: 276
Reputation: 1146
Browsers are single-threaded, so you can't simply execute JavaScript code in different threads.
But there's one exception: webworkers. But be aware that webworkers have big limitations and aren't supported in older browsers (caniuse.com).
Another thing that supports some kind of parallelism are running http calls that are waiting for the response. Those don't block running JavaScript and you can have multiple parallel waiting calls (2 due to the http spec but the real number depends on your browser). So just do some RPC calls, they will be executed in parallel. But be aware that the results will be delivered one after the other.
Let's have a look at 'The RPC's use has made the browser to pop up "irresponsive js code" warning message as the data to load is huge and takes lot of time.':
Do you really need all the data? I typically only load the data that is needed for the initial rendering of the data and IDs that are needed to load additional related data if a user clicks to show some details. Additionally, things like paging can help to reduce the data that is initially needed.
If you need all the data you could try to use Scheduler.scheduleIncremental(RepeatingCommand) to prevent the popup.
Upvotes: 1