How to apply JSON patch locally? #184
-
Hi, I'm currently working on a project that connects the local eclipse EObject model at the editor domain to the cloud server. I'm now able to send JSON patches to the server via PATCH call and receive JSON patches from the server through WebSockets. I wonder if there already exists a way from the EMF cloud server or example client implementation that I can use to apply the JSON patch to my local EObject, so the model can be synchronized with it on the server? I find out that there's a JsonPatchHelper class but I don't know if it can help with my implementation and if it does, how can I instantiate a JsonPatchHelper? Is there an example of using this helper? Or, are there any other methods to apply JSON patches to EObject at my local editor domain? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @Yunabell-VU , Yes the modelserver allows to modify the model using patches. You should use the Modelserver client, if you don't do so yet, to send patches to the modelserver. So the idea is, create a patch manually or using library like fast-json-patch. If you need more information let us know. |
Beta Was this translation helpful? Give feedback.
Hi @Yunabell-VU ,
Yes the modelserver allows to modify the model using patches. You should use the Modelserver client, if you don't do so yet, to send patches to the modelserver.
You can find an example in the coffee editor for this. The relevant code for you is this method: https://github.com/eclipse-emfcloud/coffee-editor/blob/master/client/coffee-editor-extension/src/browser/coffee-tree/coffee-tree-editor-widget.tsx#L212
So the idea is, create a patch manually or using library like fast-json-patch.
Then use the ModelServerClient
@eclipse-emfcloud/modelserver-client
to edit the model.If you need more information let us know.