Skip to content

Goals and past experiencesΒ #2

@pedr0fontoura

Description

@pedr0fontoura

Hey! This was going to be a Discord comment, but I decided to post it here for documentation purposes.

A couple of things I learned building use-colyseus:

  • The SDK should be small and precisely targeted using the state because that's where the difficulty lies. You don't need to wrap connecting, disconnecting, or any other room feature.
  • React and Colyseus are different by definition. The former uses an immutable data model, while the latter uses a mutable one.
  • Using Colyseus with React on your app is relatively easy. It takes some effort, but it's doable. Creating a general-purpose SDK to use the Colyseus state with React is hard.

The two key problems:

  • The main goal of a Colyseus React SDK is to prevent unnecessary re-renders on state updates. To do that, it needs to implement selectors properly and know exactly which piece of the Colyseus state the user is trying to access.
  • The second critical problem is keeping an immutable copy of that part of the state and tracking updates. Any update below the tracked node of the state tree needs to trigger a new copy of the node containing the updated data.

Screenshot 2024-08-18 at 22 46 01

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions