title: Asynchronous DAO in Flex / Sqlite?
body: <p><a href="http://www.adobe.com/devnet/air/flex/articles/sqlite_db_api_in_air.html" rel="nofollow">The article</a> gives a good insight of how to deal with sqlite in Flex; but it doesn't get deep into how to tackle asynchronous data access.</p>
  
  <p>For example, if I have an EmployeesDAO that does the followings:</p>
  
  <ul>
  <li>updateEmployee(emp:Employee):void</li>
  <li>findEmployee(emp:Employee):void</li>
  <li>findAllEmployees():ICollectionView</li>
  </ul>
  
  <p>etc..</p>
  
  <p>As long as the EmployeesDAO implements asynchronous mode these methods are only legitimate after the db is connected and the tables are created. The client has to know about this asynchronous nature in order to use these methods as the following will throw an SQLErrorOperation as findAllEmployees will attempt to execute a "SELECT" operation before the db is connected:</p>
  
  <pre><code>var dao:IEmployeesDAO = new EmployeesDAO();
  var employees:ArrayCollection = dao.findAllEmployees();
  </code></pre>
  
  <p>What is the best practice to deal with instantiation of the asynchronous DAO? Is it possible to hide the asynchronous nature from the client of the data access objects (i.e., the client isn't aware whether it's using sync or asynchronous DAOs)?</p>