Posted by Lena Mon, 15 Feb 2010 16:17:00 GMT

How to refactor a long chunk of asynchronous code is one thing I learned during my Javascript & CouchDB project. It's not a difficult thing, but I thought it was before I figured out how to do it, so I guess it might be interesting for Javascript newbies.

Asynchronous code

In the first couple of weeks I struggled with this new style of coding before I got the hang of it. If you're fairly new to Javascript, you're probably used to just assign a variable in one line and use it in the next line. In the asynchronous world you query for a value and do stuff with it in the callback function of the query.

To illustrate - "normal" code looks like this:

1 comment |

Posted by Lena Sun, 31 Jan 2010 21:22:00 GMT

All green!

One major pain at testing with culerity so far was a HtmlUnit bug that causes a ScriptException with PUT AJAX requests in jQuery. When you tried to test an update you got a "java.lang.IllegalArgumentException: The content cannot be null". Fortunately, this bug is fixed now. With latest HtmlUnit build culerity should run fine, and I tell you how.

I assume you have culerity installed already. If not, follow these instructions for testing Rails apps or these for testing Couchapps.

no comments |