tags:

views:

87

answers:

2

Hello!

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?

+3  A: 

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

amorfis
I did as you suggested, but it takes about 20s to draw the chart and the button that i use to start drawing keeps flashing, evethough it should be disabled until the chart is drawn. Just for test, i made the button that fetches the same data via RPC as the data that is needed for the chart, i get that data in a second or less?!
DixieFlatline
Solved, tnx for solving this little riddle.
DixieFlatline
A: 

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.

grigory