GithubHelp home page GithubHelp logo

Comments (2)

dmonad avatar dmonad commented on May 27, 2024 4

The top-level types are not defined globally - every client must define them for themselves. The idea is that one client could have another "view" on the data than another client. E.g. it is possible to do ydoc.get('document', Y.XmlFragment) (read the document as a XML data type), and another client could do ydoc.get('document', Y.Array) (read the document as an Array data structure). In the future, there might be other data types that you can use to interpret the shared data. However, I don't really recommend doing this in your case..

Another reason for not sharing type definitions globally is that it's impractical to share the type definitions of the root data types. In case the definitions mismatch (user1: ydoc.get('document', Y.Array), but user2: ydoc.get('document', Y.XmlFragment)) would have to throw an exception if we enforce everyone to use the same types. Hence, we can as well allow it, as it is technically possible.

TLDR: My recommendation is to always specify what you are expecting. Don't do ydoc.get('doc'), do ydoc.get('doc', Y.Array) instead. Your application should know what it expects.

from yjs.

himself65 avatar himself65 commented on May 27, 2024

I'm a little confused because this feature(I think it's not a bug because you mentioned it before) could cause our event listener to treat the type incorrectly

See: toeverything/blocksuite#4295

from yjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.