I'm using the relatively immature Joose Javascript ORM plugin (project page) to persist objects in an Appcelerator Titanium (company page) mobile project. Since it's client side storage, the application has to check to see if the database is initialized before starting up the ORM since it inspects the DB tables to construct the classes.
My problem is that this sequence of operations (and if this one is like this, other things down the road) takes a lot of callbacks to complete. I have a lot of jumping around in the code that isn't apparent to a maintainer and results in some complex call graphs and whatnot. So, I ask these questions:
- How would you asynchronously initialize a database and populate it with seed data using an ORM that needs the schema to be correct to function?
- Do you have any general strategies or links for async/event driven programming and keeping the call graph simple and understandable?
- Do you have any suggestions for Javascript ORMs/meta object systems that work with HTML 5 as a storage engine and are hopefully framework agnostic?
- Am I just a big newb and should be able to work this out with ease?
Thanks folks!