DixieFlatline
DixieFlatline

Reputation: 8035

How to wait until GWT RPC completes?

I am using GWT and i am making RPC calls to get some data from database. I use this data to draw charts with Google Charts API. The problem is that GWT RPC call is async and my chart is always using data from the last call, not the current one.(i populate int array in onSuccess function)). How should i wait some time to make sure that RPC completes and writes my array and then draw my chart, since there is no Thread.sleep() function?

Upvotes: 3

Views: 8778

Answers (3)

Gursel Koca
Gursel Koca

Reputation: 21300

GWT make RPC blocking

Upvotes: 0

topchef
topchef

Reputation: 19793

Another way is to use event bus and custom event to draw charts based on retrieved data. When rpc call returns with success you create this event and fire it. Appropriate controller should subscribe to the event and draw chart upon receiving it. See this on how to implement it.

Upvotes: 1

amorfis
amorfis

Reputation: 15770

You should draw chart in onSuccess(). Why aren't you?

Upvotes: 6

Related Questions