The indexedDB has a spec saying that you can access an indexed database synchronously, but it hasn't been implemented yet.
I was just wondering if there is a way to make it synchronous manually,
My JavaScript looks like this,
var trans = databaseAsync.transaction(["mapTile"], IDBTransaction.READ_WRITE);
var store = trans.objectStore("mapTile");
var keyRange = IDBKeyRange.bound(evt.data[0], evt.data[0]);
var cursorRequest = store.openCursor(keyRange);
// can you put some kind of wait in here?
cursorRequest.onsuccess = function(e)
{
var result = e.target.result;
if(!!result == false)
{
}
}
So can you put something in there to make it wait until the onsuccess method has been called before continuing on?
The reason why I want to do this is the code above is wrapped inside this method,
dojo.extend(esri.layers.ArcGISTiledMapServiceLayer, {
getTileUrl : function(level, row, col)
{
// blah
return url;
}
So it is an ESRI tile layer (which will load tiles onto a map on my web page), and that method needs to return the url straight away for a particular tile. It will either be a URL to load the image from if it isn't cached in the database already, or this,
data:image;base64,*BASE64DATA*
Where BASE64DATA is the data from the database if previously cached.
I was previously using the localStorage for this, which works synchronously, but that has a 5MB limit so I thought I would experiment with indexedDB.