I'm trying to refactor an existing project into PureMVC. This is an Adobe AIR desktop app taking advantage of the SQLite library included with AIR and building upon it with a few other libraries:
I made my current implementation of the database similar to the websql-js (http://websql-js.googlecode.com/hg/docs/websql.html
) promise based SQL access layer and it works pretty well, however I am struggling to see how it can work in PureMVC. The async SQLite library linked above uses a "SQLRunner" which maintains a pool of connections which it opens and closes as necessary.
Currently, I have my VOs that will be paired with DAOs (data access objects) for database access. Where I'm stuck is how to track the dbFile and sqlRunner instances across the entire program. The DAOs will need to know about the sqlRunner, or at the very least, the dbFile. Should the sqlRunner be treated as singleton-esque? Or created for every database query?
Finally, how do I expose the dbFile or sqlRunner to the DAOs? In my head right now I see keeping these in a DatabaseProxy that would be exposed to other proxies, and instantiate DAOs when needed. What about a DAO factory pattern?
I know from some reading and research that Cliff/PureMVC is geared to an XML database and there area already existing utilities for that, but it is too much of a refactor to move from the existing SQLite to XML.
I'm very new to PureMVC but I really like the structure and separation of roles. Please don't hesitate to tell me if this implementation simply will not work.