Skip to content

yjs Map not recommended for key-value data. #535

@collin

Description

@collin

I was looking at the recent release and saw there are yjs bindings. I've just spent some time building out yjs bindings for a mobx-keystone backed application.

One thing I encountered was using Y.Map for simple props can lead to very inefficient data storage. This is mentioned somewhat out-of-the-way in the yjs/y-utility repository.

The specific case I had was a model storing positional data: ~like

@model("Point")
class Point extends Model({
  x: tProp(types.number, 0),
  y: tProp(types.number, 0)
}) {
  @modelAction
  moveBy(x: number, y: number) {
    this.x += x;
    this.y += y;
  }
}

Due to the lack of data pruning in Y.Map while doing interleaved writes of plain values, a relatively short editing session on the order of minutes would lead to storing hundreds ok kb of data.

When I switched to using the YKeyValue utility, the stored size of my documents stays very small. I would be quite happy to use the new official bindings, but would need to find a way to use YKeyValue for plain values. Is that something you think could be ~easily supported by the official bindings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions