On Jul 27, 2009, at 12:54 PM, Maciej Stachowiak wrote:
On Jul 27, 2009, at 12:55 PM, Nikunj R. Mehta wrote: <snip>
JavaScript actually lets you write a series of nested callbacks in a way that looks almost like straight-line code, by using function expressions:db.transaction(function(tx) {tx.executeSQL("SELECT UserID FROM Users WHERE UserName = ?", [userToBan], function(tx, firstResultSet) {if (resultSet.rows.length > 0) {tx.executeSQL("INSERT INTO BannedUsers VALUES (?)", resultSet.rows[0]);} } }); (Sorry for the contrived example and my likely syntax errors.)Granted, this gets awkward if your logic gets considerably more complicated.
And mine did get awkward, very quickly. I found it really hard to keep myself sane through the development of asynchronous code that executes transactionally and involves multiple sql statements.
My argument is that the program logic gets really complex, really fast if you are doing anything complex using Database. On the other hand, if your logic and SQL needs are really simple, you might as well use the DatabaseSync interface and pay the price of marshaling and unmarshaling, which may not be that much.
Alternatively, perhaps, we should consider doing something in WebWorkers to deal with the overhead of sharing JavaScript objects across VMs.
Nikunj http://o-micron.blogspot.com
