Reputation: 15413
Following the Storage doc on MDC I've written something to read some history and show it in a textbox:
var dbConnection = database.getDBConnection();
var getHistoryStatement = dbConnection.createStatement("SELECT destinationUrl FROM uploadHistory ORDER BY id DESC");
getHistoryStatement.executeAsync({
handleResult: function(aResultSet){
var newHistoryString = "";
for (var row = aResultSet.getNextRow(); row; row = aResultSet.getNextRow()) {
newHistoryString += row.getResultByName("destinationUrl") + "\n";
}
document.getElementById("historyText").value = newHistoryString;
},
handleError: function(aError){
},
handleCompletion: function(aReason){
}
});
However this is failing because handleResult is getting called twice on different threads: one with the first 3 results and one with the rest of the results. I can't find anything in the docs about this behavior and google turns up nothing. Anyone know of this behavior or how to get handleResult to be called only once with all the results?
This is running on Firefox 4.
Upvotes: 0
Views: 681
Reputation: 4682
I don't think you mean to say it was getting called on different threads; the callback is always invoked on the thread that executeAsync
was called on. handleResult
can be called more than once, and that behavior is documented (although you may not have looked at that page).
Upvotes: 3