Wednesday, June 26, 2013

A Promise to IndexedDb

Quite a bit of my free time in the last 8 months has slipped away into OJ, my solution to the hell of dynamic form creation (based on arbitrary data inputs and accordingly arbitrary data outputs). Folks at WuFoo and Bootsnip have some nice prototypes of runtime manipulatable engines; while each looks like excellent work, neither solves my problem of generating entire workflows based on data. I want the data to drive the UI; the UI should simply read the data and generate the necessary rich form content necessary to provide slick, intuitive, addictive user experiences.

In the pursuit of this heffalump, I had recently been working on decomposing Martin Orth's query builder into classes in the OJ framework (see it on Github, in NPM, and collaborate with me in Cloud9). This body of work depends upon ExtJs, which is a powerful but extraordinarily inscrutable framework. I spend a frustrating amout of time comparing the inputs into Ext from OJ vs the inputs in Sencha's examples or their documentation. It's tedious and fragile as seeming minor changes can produce difficult to track bugs which go unobserved across several commits.

I wanted to be able to instrument my code in such a way that I could flip a switch and start logging every input into Ext. I had a few requirements: the objects logged needed to be in as close a state as possible to their values at the time of logging (logging to the console sends the object by reference, so you'll usually get the last known value of the object by the time you see it). The objects needed to persist across page loads. There would be a lot of data (more than would fit in localStorage). Finally, the data needed to be queryable.

IndexedDb seemed like a potentially good fit. Unfortunately, like so many "HTML5" standards, the API is terrible. If the consumers of this API were just vendors, like Chrome and Firefox, it would be hard to identify any specific contract as "wrong"; but as a developer consuming this API, I cannot easily point to any component and say, "this is right." But it is what it is, and it is all we've got.