I have an asynchronous call to a web service that retrieves data. This data is then parsed out, and stored in Rhom.
Because there are quite a few records, the saving into Rhom can take up to 20 seconds on the RhoSimulator.
I found this article to do with saving large amounts of data, so thought I'd try and implement it
The code I have is as follows:
:url => url,
:callback => url_for(:action => :download_callback))
render :action => :wait_download
if @params['status'] == 'ok'
@@parsed = Rho::JSON.parse(@params['body'])
WebView.navigate ( url_for :action => :start_objects_generator )
#callback has to be provided, overwise operation will be syncronous
:url => url_for(:action => do_objects_generation),
:callback => (url_for :action => :generation_callback))
render :action => :wait_update_rhom
#If you create a lot of objects enable GC at the beginning of action
#Do some heavy operations
@@parsed.each do |item|
#Save off records to Rhom
WebView.navigate ( url_for :controller => :Event, :action => :index )
As you can see, the do_download function makes a call to the web service, and renders a wait page (wait_download)
When this call completes, I am then telling the web view to navigate to start_object_generator, which then makes another asynchronous call to the controller action do_objects_generation.
I then tell it to render a new wait page, which contains a progress bar (wait_update_rhom).
The problem is that this new wait page is not rendered, and it merely sits on the previous wait page until the second asynchronous call is completed.
Is there any way around this, or am I doing something wrong?
Thanks in advance.