[DataCache] Event Handlers on DataCache

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

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".

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

- Joe

Received on Thursday, 17 December 2009 07:36:51 UTC