[feature] Allow changing arbitrary options during room lifetime (disconnectOnPageLeave implemented)#1358
Conversation
Also only call `removeEventListener` in handleDisconnect() when actually registered before.
|
This is required to adhere to @typescript-eslint/no-unused-expressions
|
thanks for the suggestion! I think we'd want to expose dedicated (feature based) methods instead of relying on a proxy for these kind of things. WRT your use case of custom page leave behaviour, I think it makes sense to leave |
|
I can completely follow your point to expose dedicated (feature based) methods instead of relying on a proxy for these kind of things as being a solid design decision. So i'm just leaving this feature branch here which – as said – was just a suggestion.
This is of course what i ended up doing, at least for the moment as i didn't want to rely on my custom build of client-sdk-ks ;) Option A would be to expose dedicated methods as you said. |
This is a proposal (or an RFC if you want) implementing a Proxy on the
Room.optionsproperty. This enables to switch options on or off that otherwise can only be configured once on instantiation. Potential applications could be to haveadaptiveStreamordynacastswitches in the example applications, but basically any option can be made configurable at runtime with it.As a proof-of-concept and first application, this PR implements updating
disconnectOnPageLeaveafter the Room has been created, because that was my XY-Problem that led to this: I wanted to hook up abeforeunloadhandler so a user confirmation is shown should they navigate away during a LiveKit session that is being recorded. The problem i discovered was that the room was being disconnected anyway after the user chose to stay on the page in the confirm dialog. Digging into the library i realized i had to initialize the Room withdisconnectOnPageLeave: false– however i felt i don't want to lose this very sensible default behavior. So i implemented this Proxy, which enables to simplyroom.options.disconnectOnPageLeave = falsewhen recording starts and my custombeforeunloadhandler is registered, and vice versa doroom.options.disconnectOnPageLeave = truewhen recording stops.