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

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