Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying functions OR booleans for storage/presence mappings #933

Open
dabdine opened this issue Jun 8, 2023 · 1 comment
Open
Labels
feature request Feature requested by the community

Comments

@dabdine
Copy link

dabdine commented Jun 8, 2023

Is your feature request related to a problem? Please describe.

We're using ReactFlow with Liveblocks. ReactFlow is a graphing library. We store our nodes and edges (arrays) for the graph visualization in Zustand. We want all collaborators in our product to share the same view of the graph, so our nodes and edges are set to true in the storageMapping property of the liveblocks wrapper around our Zustand state.

However, in certain cases, we do not want to synchronize parts of the nodes and edges. For example, let's say there's a className attribute in a node:

[{ id: "1234", className: "foo" }]

If we were to supply a className value for dark mode when the user switches their theme, it would replicate the same className to other collaborators connected to the room.

Therefore, I'd only like to synchronize a partial of the object, in this case the id:

[{ id: "1234" }]

even though my zustand state should remain having both fields.

Describe the solution you'd like

I'd love the ability to specify a function that dictates filtering and merging logic that can be used outbound and inbound (respectively) so I can keep my zustand state the same while specifying how liveblocks should deal with state synchronization.

Something like this, but this is pretty clearly only supporting the filtering case:

storageMapping: {
  nodes: (nodes: NodeType[])  => [...nodes.map((n) => ...)]
}
@dabdine dabdine added the feature request Feature requested by the community label Jun 8, 2023
@Arun-chaitanya
Copy link

@dabdine I have good experience with the tech stack you guys are using. Can I contribute to liveblocks via this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature requested by the community
Projects
None yet
Development

No branches or pull requests

2 participants