My IndexedDB recording, and a few notes

This post is more than 2 years old.

Here is the recording URL for the presentation I just gave on IndexedDB:

You can find the full source code for the demos and slide deck here:

Now for some random notes:

I plan on writing up this presentation as an article (not sure for whom yet, maybe Smashing Mag). But basically, I'm going to turn the presentation and demo assets into a guide that can be downloaded, read offline in the bathroom, etc.

Secondly, one topic I didn't go into, but bit me in the butt today, was the transaction object's "oncomplete" handler. This comes into play when doing something like this:

Add some crap. Run a method to get all crap so I can see it listed.

I've had a "Note Database" demo in my presentation for a while now and it worked fine... until today. When I presented it today (and you can see my surprise in the recording), I noticed that my add/edit/delete operations were not updating the list of notes. Why? Because I was asking the system to refresh the notes in the success handler of the request (where the request was either add/edit/delete). Instead, I needed to wait for the transaction to end as a whole.

As an example of this mistake, here is my original code for delete:

Notice that displayNotes() is in the request success handler. Here is the corrected version.

I've broken up my chained calls there a bit so I get access to the transaction and add the oncomplete there.

Previously this wasn't required in Chrome, so I'm assuming something has changed, but to be honest, this feels like the right way of doing things anyway.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Nirav Patel posted on 3/1/2013 at 6:09 PM

Thanks Ray for the solution.......
Same issue with me recent but I didn't find correct solution.....
Once again thanks Ray......

Comment 2 by Raymond Camden posted on 3/1/2013 at 8:07 PM

You mean you had the same issue with transactions I did?