GoogleChrome/experience-sampling — pull request #57 by christhompson (2014-10-26 01:05:39+00:00)
Title: Use IndexedDB to save and process survey submission queue

This adds functions to save completed surveys to an IndexedDB database, and to process and send surveys that are in the database. Failed submissions cause exponential delay. Successful submissions cause the survey to be deleted from the database.

Turns out that LocalStorage alone isn't good enough because otherwise you can run into weird race conditions with the event loop. Transactions are painful but very helpful. This is my first time working with IndexedDB, so this took me a while to figure out (and to try to make sure there weren't weird race conditions and such). Also JavaScript closures are gross, but necessary. Hopefully there isn't too much that needs editing, but having another pair of eyes to look at this in it's current state would be good.

This fixes issue #37