Re: [DataCache] Event Handlers on DataCache

On Dec 16, 2009, at 11:36 PM, Joseph Pecoraro wrote:

> There are a number of new event handlers on the DataCache interface:
> http://dev.w3.org/2006/webapi/DataCache/#async-datacache-interface

In the revised spec, event handlers are defined on the  
CacheTransactionRequest object only.

>
> Before (and still) tasks are queued at the cache host level (document)
> and can be caught like so:
>
>  // Handle any cache events
>  document.addEventListener('fetching', function(event) {
>    var cache = event.cache;
>    ...
>  }, false);
>
>
> Now there are event handler attributes are on the DataCache itself
> meaning you should also be able to do:
>
>  var cache = window.openDataCache();
>  cache.onOfflineUpdate = function() { ... };
>
> I see a potential problem with the "onFetching" event. When you create
> an online transaction from a data cache, a new data cache is created:
> http://dev.w3.org/2006/webapi/DataCache/#starting-a-transaction
>
> [[
> Create a new data cache, called data cache, in cache group which
> holds all the same resources as the relevant data cache of cache  
> group.
> ]]
>
> In such a case the "onFetching" event seems to have a problem.
>
>  var cache = window.openDataCache();
>  cache.onFetching = function() { ... }
>  cache.onlineTransaction(function(tx) {
>    // NOTE: this created a new cache
>  });
>
> If the onFetching event is intended to fire on the old cache, then
> I suggest a Note of some sort be added to the Specification to
> clarify this.
>
> The problem does not exist for offlineTransactions, which
> reuse the current cache, and never fire "onFetching".

This event is no longer used.

>
> Also, are new APIs switching to camel case for event handler
> attributes? I've always seen them all lowercase.

That was a typo and has been corrected.

Nikunj Mehta
http://blog.o-micron.com

Received on Friday, 1 January 2010 19:00:02 UTC