-
Notifications
You must be signed in to change notification settings - Fork 25
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
Redux Binding? #137
Comments
Thanks for sharing @SebastianStehle, this looks cool! And the timing is great, we've been thinking a lot lately about interfaces between Yjs and frontend UI/state libraries. My Redux knowledge is a bit dated now, do you have an example of what some application-side code in a reducer would look like? I'd love to help you get it set up with y-sweet, let me know if there's anything I can help with. |
Usually the reduxer is just a function like (state, action) => state. So it returns a new state based on the old state. There are several ways to do that:
The class based approach is more exotic, but it was needed for my case. Because yjs is not immutable, we cannot use the types directly. Therefore the redux library is responsible to update abstract types from the diff of the current and the previous state and to create a new state from the old state and the events. It is a little bit more complicated, but this is described in the readme. The API surface is very small. It basically looks like this:
You create the binder, that registers a middleware and a reducer to the store. The reducer is needed to accept the incoming changes (because there is no API for something like Then |
I have tested y-sweet with mobx and https://syncedstore.org and works perfectly well. Not sure about the yjs-redux tho. |
Hi,
I really like your project. I have created a binding for redux and ideally I would like to integrate it to an existing platform. Either the yjs organization or your service.
My project URL: https://github.com/SebastianStehle/yjs-redux. Your review and feedback is very welcome.
I actually created the project for https://github.com/mydraft-cc/ui and I think I will use y-sweet to add collaboration.
The text was updated successfully, but these errors were encountered: