liveblocks icon indicating copy to clipboard operation
liveblocks copied to clipboard

Clean up Room subscription internals using new `EventSource` abstraction

Open nvie opened this issue 3 years ago • 0 comments

We currently have a lot of support code inside the Room's state machine to manage several event queue callbacks that can be subscribed to using a single exposed room.subscribe() API. This setup means a lot of boilerplate: many local variables exist in the function scope, manual .push()'ing and looping-to-notify manually.

This internal complexity could be simplified by using EventSource API I added as part of the useSelector() API work.

This would make the internal implementation of the Room simpler and as a result easier to debug or reason about.

Ultimately, the implementation of room.subscribe() can be simplified a lot as well if we do this.

nvie avatar Jul 14 '22 13:07 nvie