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

Regression in v13.6.13 and up #632

Closed
rustysys-dev opened this issue Apr 20, 2024 · 2 comments
Closed

Regression in v13.6.13 and up #632

rustysys-dev opened this issue Apr 20, 2024 · 2 comments
Assignees
Labels

Comments

@rustysys-dev
Copy link

Describe the bug
https://discuss.yjs.dev/t/breaking-change-introduced-in-v13-6-13/2599

The changes to the Doc Type breaks builds in code which was making use of the ability to create custom events on the doc.

To Reproduce
Steps to reproduce the behavior:

  1. Create an instance of doc
  2. Create an on.('non-defined-event', ...)
  3. Attempt to emit that event
  4. The typescript compiler throws an error.

Expected behavior
we are able to create custom events

Screenshots
image

Environment Information

  • nodejs ^18
  • yjs v13.6.13, yjs v13.6.14
@rustysys-dev rustysys-dev changed the title Breaking change in v13.6.13 and up Regression in v13.6.13 and up Apr 20, 2024
@dmonad
Copy link
Member

dmonad commented Apr 23, 2024

I'm sorry that this breaks your existing codebase. However, I don't want to revert to an untyped event system.
There is a big advantage in having typed events.

The only way I see to "fix" this is to allow user-defined events that you can define on Yjs using typescript. E.g. new Y.Doc<{ error: ErrorObject => void }>()

However, I also don't want to do that. There is a good chance that I eventually want to define the "error" event in Yjs. Now, if I allowed custom events, then I would break everyone's codebase whenever I added a new event. This would lock me in, making me unable to add custom events on the data type I maintain, while allowing only users to add new event types.

I also dislike it when it's not clearly defined who owns something (e.g., is the error event fired by you or by me?).

I didn't intend for users of Yjs to fire their own events using the Yjs object. Now, with the type event system it is made clear that this is not possible.

Therefore, I see the burden on you to build your own event system - possibly by wrapping Yjs in a custom datatype. I'm sorry, this is probably not what you wanted to hear.

@dmonad dmonad closed this as completed Apr 23, 2024
@rustysys-dev
Copy link
Author

@dmonad no problem at all, and the direction is understandable. I mainly only pointed it out because it happened in a patch version. Otherwise I wouldn't have.

Thanks for all your hard work on this project!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants