W3C home > Mailing lists > Public > public-webrtc@w3.org > November 2012

Re: [ACTION-59] Introduce lookup by id structures for streams and tracks.

From: Adam Bergkvist <adam.bergkvist@ericsson.com>
Date: Mon, 5 Nov 2012 15:36:33 +0100
Message-ID: <5097CEF1.3060601@ericsson.com>
To: Anant Narayanan <anant@mozilla.com>
CC: "public-webrtc@w3.org" <public-webrtc@w3.org>
On 2012-11-05 14:59, Anant Narayanan wrote:
> On 11/5/12 5:36 AM, Adam Bergkvist wrote:
>> Here are two options on how to solve item 2) (iteration) from the list
>> above. I you have a better approach, feel free to suggest it.
>>
>> A) forEachStream()/forEachTrack() method
>>
>> You iterate through all the items by providing a callback to the
>> forEachStream() method. The callback will be called synchronously for
>> each item.
>>
>> Example:
>> pc.localStreams.forEachStream(function (stream) {
>>      // use stream
>> });
>>
>> We could have the callback return a boolean value which could be used to
>> "break" the iteration if the desired item was found before the end was
>> reached.
>
> Why not simply .forEach?
>
> Between A and B, I prefer the forEach approach, but I think we can just
> reuse the .forEach already specified for arrays instead of introducing a
> new method.

forEach() works for me. I had that in mind when I wrote the proposal, 
but wanted to differentiate the collection object from arrays a bit.

/Adam
Received on Monday, 5 November 2012 14:36:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:17:35 UTC