Reputation: 555
I'm using Vue.js and I keep track of all Participants in a Vue data array called participants
. Initially when a Participant connects, I push them into this array, which with the help of v-for, will produce the to-be container for the Participant's media. Once the container is ready, I use the ref to locate it and do track.attach()
to add the Participant's tracks to it.
Upon removal, is there any specific reason to use track.detach()
versus simply removing the Participant from the participants
array in my case, leading to the destruction of the HTML element containing the tracks? Does this have any effect on any events fired or does it cause problems with disconnecting?
Upvotes: 1
Views: 84
Reputation: 73065
Twilio developer evangelist here.
When you call detach there is a bit more work that gets done, mainly the removing of the mediaStreamTrack
from a MediaStream
object the track keeps track of. You can see the code for detaching the track here.
I am not sure on this, but as long as the track itself is eventually discarded then the mediaStreamTrack
and MediaStream
will also be discarded and there won't be a memory leak. It doesn't have, as far as I know, any effects on disconnecting or other events.
Upvotes: 1