Tag Archives: Open Source

OfflineSaveQueue, an HTML5 Local Storage Solution


I created a new JavaScript library called OfflineSaveQueue.  The purpose of this library is to temporarily save JSON objects in HTML5 Local Storage in the event that an internet connection is not available.

The creation of this library arose out of my need to save data to Parse.com from a PhoneGap application.  The app was not guaranteed to have internet connectivity so I needed a way to put the data in a temporary queue where it could be kept until I got a success callback from Parse.

OfflineSaveQueue is not being maintained anymore and I don’t recommend using it.  However, if interested you can still take a peek at the GitHub repository.

Usage of OfflineSaveQueue is simple:

Instantiate an OfflineSaveQueue object:

var offlineSaveQueue = new OfflineSaveQueue();

Set the callback function which is executed when the queue is processed:

offlineSaveQueue.setCallback(function(objectInstance, objectName){

//Do stuff here...

});

Start periodic queue processing:

offlineSaveQueue.startQueueProcessing(60000);

Stop periodic queue processing:

offlineSaveQueue.stopQueueProcessing();

Save an item into the queue

offlineSaveQueue.saveObject({"foo": "bar"}, "DummyObject");

Manually process the queue

offlineSaveQueue.processQueue();

Get the number of items in the queue:

offlineSaveQueue.count()