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

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 UTC