Git Product home page Git Product logo

y-presence's People

Contributors

dependabot[bot] avatar nimeshnayaju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

y-presence's Issues

Can we implement using WebRTC?

Hi,
This may be a very silly and rookie question. Can we implement live cursors using WebRTC instead of WebSocket?
I tried but looks like only local user state is set and tracked.

ERROR in ./node_modules/y-presence/dist/index.mjs 2:0-99

Hi, i am currently working on team project using yjs, y-presence and react(typescript).
i got this error and i can't solve it. can i please get some help? thank you in advance.

ERROR in ./node_modules/y-presence/dist/index.mjs 2:0-99
Module not found: Error: Can't resolve 'use-sync-external-store/shim/with-selector' in '/Users/kcw2297/Desktop/Drawing-Duo/node_modules/y-presence/dist'
Did you mean 'with-selector.js'?
BREAKING CHANGE: The request 'use-sync-external-store/shim/with-selector' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

Feature request: filter current user

Thanks for the library, it is great. Also would be nice to have an ability to return only other users from useUsers. Maybe useUsers should have optional options argument for selector function and equality function, where in addition excludeSelf could be presented. What do you think?

Example:

const otherUsers = useUsers(awareness, {
  selector: (state) => state,
  excludeSelf: true,
});

Issue when using with tiptap collaboration cursor

useSelf works well in most situations. But when I use it with TipTap editor and CollaborationCursor extension here comes an issue:

In a component that renders tipTap editor I need to update the presence of the user like this:

const self = useSelf();
useEffect(() => {
  if (!self || !editor) return;
  editor.commands.updateUser({
    name: self.username,
    color: self.color,
  });
}, [self, editor]);

Unfortunately this code makes tiptap editor opened websocket to go mad and infinity send a huge amount of messages.

I have create this hook:

import { isEqual } from "lodash-es";
import { useSelf as usePresenceSelf } from "y-presence";

export const useSelf = () => {
  const self = usePresenceSelf(awareness) as YUser;
  const selfRef = useRef(self);
  useEffect(() => {
    if (isEqual(self, selfRef.current)) return;
    selfRef.current = self;
  }, [self]);
  return selfRef.current;
};

Now update is working as expected and there is no infinite loop of messages anymore.

Should this be added in the y-presence lib? What do you think?

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.