livekit / client-sdk-android

LiveKit SDK for Android
https://docs.livekit.io
Apache License 2.0
180 stars 75 forks source link

Use immutables for flows #101

Open davidliu opened 2 years ago

davidliu commented 2 years ago

State flows won't refire for internal changes within objects. Need to create immutable versions for flows.

AchrafAmil commented 2 years ago

Definitely +1

Tried this, expecting it to fire when camera flips between front/back but it didn't — the track instance is the same.

room.localParticipant::videoTracks.flow
    .map { (it.firstOrNull()?.second as? LocalVideoTrack) }
    .collect { /* set renderer mirror */ }

Unfortunately I see no room.events that gets triggered when I flip camera (by changing options and restarting the track).

davidliu commented 2 years ago

@AchrafAmil note that the track isn't replaced when camera is flipped; the LocalVideoTrack instance remains the same.

AchrafAmil commented 2 years ago

Yes! Until it's made immutable and would therefore inevitably be a new instance.