On Wed, Aug 24, 2011 at 12:57 PM, Charles Pritchard <ch...@jumis.com> wrote: >>> Prpoposed: >>> >>> FormData output with the x-www-form-urlencoded mime type: >>> formData.toUrlEncodedBlob(xhr.send) >>> >>> If going down the blob path, these two would have the same end-result: >>> formData.toMultipartBlob(xhr.send) >>> xhr.send(formData); >> >> What kind of API-style is this? >> > [Supplemental] FormData > void toMultipartBlob(in callback) > void toUrlEncodedBlob(in callback) > > The first would create a multipart mime message, in a blob, and run the > callback with the blob as the first argument, > the second would create a urlencoded message, in a blob, and also run the > callback. > They'd set the appropriate content type on generated blob.
The syntax you've written above wouldn't work in JS. You're only passing in a reference to the send function, not a reference to the XHR object on which to call .send on. So formData.toMultipartBlob(xhr.send) is equivalent to formData.toMultipartBlob(XMLHttpRequest.prototype.send) So in this case you'd have to pass in two argument, the function and the 'this' object. Or require people to use .bind. In general I'm not a fan of this syntax. / Jonas