What is the best way to implement a "shared number"?

In my application, I need to share not only texts and nodes but also numbers.

There is no official shared type for that. What would be the most optimal way?

I can think of:

  • using an array with a single value,
  • using the meta field of a document.

I can’t find doc about the meta field so I don’t know what its use cases are.

What operations can users perform on the number, and what range will the number be in?

If users just set the value to any number, and whoever writes the number last wins, then you could just use a Y.Map and set a specific key to the number.

Any operation. So a “set value” :stuck_out_tongue:

Would there be some performance / encoding size advantage to use an Y.Array vs a Y.Map?

Simply use ymap.set('my number', 42) to update a number and ymap.get('my number') to retrieve it. I think it’s that simple.

The Y.Map is the easiest solution for a key-value store. It doesn’t matter what you store in it.

That will do it, thank you both for your responses.