RUBY RHOELEMENTS RHODES
Coordinate the startup of a Rhodes application. These methods are in the application.rb file.
The initialize method is generated in the application.rb file. Put your application initialization code here.
class AppApplication < Rho::RhoApplication def initialize # put initialization code here end end
You can define the following AppApplication class methods in your application.rb file to listen for activation, deactivation, and upgrade events:
Write the on_ui_created method in the application.rb file to run code after your application’s UI is created (such as at application start).
def on_ui_created # put your application UI creation code here # for example, create tab bar: # NativeBar.create(Rho::RhoApplication::TABBAR_TYPE, tabs) super # To navigate to start_path from rhoconfig.txt end
Write the on_ui_destroyed method in the application.rb file to run code after your application’s UI is destroyed (such as at application exit).
def on_ui_destroyed # put your code here # example: # @forbid_ui_operations = true end
Write the on_ui_destroyed method in the application.rb file to run code after your application is activated.
def on_activate_app # put your application activation code here end
Write the on_ui_destroyed method in the application.rb file to run code before your application goes to the background. Don’t call any UI operations here, they’ll be ignore (for example, WebView.refresh
).
def on_deactivate_app # to stop sync background thread call # SyncEngine.stop_sync; SyncEngine.set_pollinterval(0) # To stop local web server when application switched to # background return "stop_local_server" # return "stop_local_server" end
Write the on_reinstall_config_update method in the application.rb file to run code when your application is upgraded.
conflicts
is a hash name to an array of conflicted values (old local value, new upgrade value) for any conflicts for the properties in rhoconfig.txt. By default, the local values are kept in place, but you may overwrite them with new values in the conflicts
array.
def on_reinstall_config_update(conflicts) # puts "on_reinstall_config_update: #{conflicts}" end