0 Replies Latest reply on Aug 17, 2011 9:45 AM by habefast

    How to get notified when offline changes are successfully applied ?




      I'm currently experimenting with the offline / sync capabilities of LCDS. My concern is to get notified when a write operation has been done, whether we are working online or offline from the server. This way, my code has a consistent behavior whatever the connection status is. According to the docs and examples found online, the usual way to do it is using an AsyncToken / ItemReference returned by the write operations.


      This works perfectly well when online, my callbacks are triggered correctly. But when working offline, I'm facing two problems :

      • if I enable autoCommit, the calls to "createItem()", "updateItem()", and "deleteItem()" all throw an exception because we try to call the service on server while offline ;
      • if I disable autoCommit and manually call "commit()" when appropriate (i.e. only when connected), I don't get any error (and all the operations will be replayed once reconnected), but I no longer get the callbacks from the AsyncTokens...


      I found a solution in the sample app from Christophe Coenraerts, where he disabled the autoCache feature and thus uses the callback from the "merge()" operation to trigger actions. But I find this weird from a code point of view. We want to listen to individual events, not a generic event that may include multiple operations at once.


      Is there any mean to use the same callbacks for both offline and online mode ?


      Many thanks in advance for your help