liveblocks / liveblocks

Liveblocks is the platform for adding collaborative editing, comments, and notifications into your application.
https://liveblocks.io
Apache License 2.0
3.51k stars 281 forks source link

[DOC_REQUEST] - Does leave automatically unsubscribe all handlers? #598

Closed talksik closed 1 year ago

talksik commented 1 year ago

What is the improvement or update you wish to see? Simply want to know more details of what different api endpoints do.

Is there any context that might help us understand? I would like to know if it is important for us to clean up and what the point of the unsubscribe functions are.

Thank you so much!

taylorpwhipp commented 1 year ago

Hi Talksik,

When leaving a room, unsubscribe is not called, however you are closing the connection to a room.
Because of this, events that you were subscribed to should not continue to trigger storage updates. Is that something which you have seen?

The main purpose of the subscribe function is similar to adding an event listener in javascript, and unsubscribe would correspond unbinding that listener-- so perhaps you only wanted to trigger subscribing to an event or unsubscribing to an event based off certain conditions or triggers.

Does that help clarify?

talksik commented 1 year ago

Got it thank you so much @taylorpwhipp!! Appreciate the detailed response.

I am now curious why my connections are inconsistent with turning off when a client's computer goes to sleep. Is there some delay in pinging clients to check connection?

I have had a case where client A saw that client B was connected for hours even when client B computer was in sleep mode.

talksik commented 1 year ago

Closing this as going to take the above comment to this thread : https://github.com/liveblocks/liveblocks/issues/679