W3C home > Mailing lists > Public > public-media-capture@w3.org > December 2011

Re: Callback style for GetUserMedia (Re: First draft available)

From: Harald Alvestrand <harald@alvestrand.no>
Date: Thu, 01 Dec 2011 05:01:17 +0100
Message-ID: <4ED6FC0D.6040405@alvestrand.no>
To: Brian LeRoux <b@brian.io>
CC: Anant Narayanan <anant@mozilla.com>, Robin Berjon <robin@berjon.com>, Stefan Håkansson LK <stefan.lk.hakansson@ericsson.com>, public-media-capture@w3.org
On 12/01/2011 12:28 AM, Brian LeRoux wrote:
>> I'm a bit dense, but please bear with me .... what is the reason why this is
>> an advantage?
> code is more succinct / less indentation ceremony
>
the code for the callback will have another level of indentation

First case:

function success(stream) {
    do something with stream
}

function failure(err)
    do something with err
}

function eithersuccessorfailure(err, stream) {
    if (err == ok) {
       do something with stream
    } else {
       do something with err
    }
}

6 lines in the first case, 7 lines in the second case.
1 more level of indentation in the second case.

I still don't get it.

I still don't see it.
Received on Thursday, 1 December 2011 04:06:53 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:14:58 GMT