7 Replies Latest reply on Apr 18, 2014 10:45 AM by Hector Meza

    RhoConfig javascript?

    Ruben Ruben



      Is the RhoConfig API also available in Javascript? If so, how do I use it?

      If not: what should I use to store user settings?



        • Re: RhoConfig javascript?

          The RhoConfig API is no longer available as of the RhoElements 4.0 release. You should use the Runtime configuration instead, found here:

          Rhomobile | Runtime Application Configuration

          1 of 1 people found this helpful
            • Re: RhoConfig javascript?
              Ruben Ruben

              Hi Michael,


              I've read the docs, but I think I don't fully understand: I see in the first section an example that uses Rho::RhoConfig.start_path. Is that correct, or is that deprecated?. In my previous attempt, I assumed that the Javascript way of accessing the rhoconfig.txt start_path variable would be: Rho.RhoConfig.start_path, but RhoConfig seems to be 'undefined'.


              I took a look at the config.xml part, in case that was what you meant by "Runtime configuration", but I had understood this was used for RhoElements internal configuration, and not to add app-specific config variables.


              My use case is that I want the user to be able to save some settings, like the username, and some preferences on how thedata is sorted in the views. I had previously done this with RhoConfig in RhoElements 4.0 from Ruby, by just creating a new variable in the config that would get saved to the rhoconfig.txt.


              What is the correct way of adding new app-specific config variables that get stored?



              • Re: RhoConfig javascript?
                Jon Tara

                RunTime Configuration isn't the same thing, though.


                RhoConfig contains values used by the Rhodes server. As well, you can add your own items.


                Config.xml contains values used by RhoElements. The docs don't state that you can add your own items. There doesn't seem to be any interface to read these values in Ruby. (I guess you could open the file and parse the XML, ugh!)


                There is no replacement for RhoConfig in Ruby. It seems to me the Javascript version was removed for no good reason.


                Doesn't affect me, since I don't use RhoElements.


                We have a bunch of our own keys in rhoconfig.txt, and RhoConfig in Ruby still works as always. Though we've been moving a bunch of these (our own keys) to a pre-processing step using {{mustache}}. since for the most part they are static values determined a build-time.


                Frankly, we've probably abused RhoConfig to hold stuff that really belongs in the database.

                  • Re: RhoConfig javascript?
                    Ruben Ruben

                    I ended up creating a AngularJS factory and a ORM model to store my settings on it. I can't help it but I feel this is a little ugly, if someone knows a better approach, i'd like to hear it.

                      • Re: RhoConfig javascript?
                        Hector Meza

                        Ruben, the config aka Rhoconfig API is a legacy API that is accessed via Ruby and has not been migrated forward to JS.  The intent of this API is to access Rho system runtime parameter.


                        You mention that your use case is to allow user to be able to save some settings, like the username, and some preferences.  This sounds like dynamic data storage as each user could be different and they may want to change the settings from time to time.  With this type use case, the data (settings) should be stored in a file that your application has control over and not a System controlled file.  You can take several approaches 1) Create a model (table ) in your DB with 1 record and all the settings (what you have done with Angular).  you could also do the same with the built-in Rhom.  2) you can include a fixed file in you project and  read and write to it with the settings i.e. Json or txt.  This would serve the same purpose as the Rhoconfig.txt file but it would be tied to your application and not the Rho settings.