[dojo-contributors] Dojo 1.9 Proposal

Kitson Kelly me at kitsonkelly.com
Wed Oct 17 09:59:11 EDT 2012


Sorry if I am confusing people, but the two items Dylan stated were my
intention, however badly stated.  Though the mechanisms are not yet fully
fleshed out, though after some of the conversation here and further back of
the mind thinking, I see two clear points:

   - A consistent interface to persistent local storage that is dojo/store
   compatible.  This transparently support IndexDB and Web Storage (and maybe
   other forms of persistent local storage).  This could be accomplished in
   a similar fashion to the way dojo/request works in detecting the
   appropriate platform via the has API, which of course can be overridden by
   a developer directly accessing the appropriate module.  This means in most
   use cases an end developer just needs to require a single module (e.g.
   "dojo/store/LocalStorage") and they are abstracted from the specifics of
   the user agent and the specific API implementation.
   - A second module that is an "intelligent" cache that is a configurable,
   cross store, transaction coordinator.  Again, abstracting the end developer
   from the specifics of the implementation, it would handle applying
   transactions across a set of stores, in memory, local and remote.

I would envision something like this:

require(["dojo/store/JsonRest", "dojo/store/LocalStorage",
"dojo/store/Memory", "dojo/store/Sync"],
function(JsonRest, LocalStorage, Memory, Sync){
  var jsonStore = new JsonRest({ target: "/items/" }),
      localStore = new LocalStorage({}),
      memoryStore = new Memory({});

  var store = new Sync([jsonStore, localStore, memoryStore], {});
  var item = store.get(12345);
  item.foo = "bar";
  store.put(item);
  store.flush();
});


The appropriate events could be emitted on the Sync to deal with atomic
transactions, committing of the transactions across stores, handling of
offline behaviour, etc. though the most "generic" behaviour would occur so
that the end developer wouldn't have to be consciously aware of
the implementation.  I know that can open up the door for end developers
doing stupid things, like using persistent local storage improperly, but
that should prevent us from building on top of the raw power of the user
agent and serving it up in a consistent fashion.  With the above, I don't
have to know about IndexDB or Web Storage.  I have a simply, consistent
pattern that I can apply, which automagically works with by data aware
widgets and in most cases, deals with the "tough things" for me, but also
is open enough for me to "plug" into it to change the behaviour once I
realise I have an edge case that I need to deal with, or tune the
performance.

Regards,
Kit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20121017/20ac64ef/attachment.htm 


More information about the dojo-contributors mailing list