-
Notifications
You must be signed in to change notification settings - Fork 14
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
Going async or implementing batch patch collection #7
Comments
AFAIR, this asynchronous manner was a problem for us many times. However it's a valid point we may have used to it so much, that now sync would become a problem. I'd either
But we can discuss it on the upcoming meeting |
Thanks for the idea @alshakero and thanks @tomalec for the counter-idea :) I think that sync is worth trying in something that we can call If we discover problems with sync, then I strongly propose to re-introduce async on the Palindrom level, not on the JSONPatcherProxy level. To remix the great simple code from @alshakero, Palindrom would do sth like: clearTimeout(lastTimeout);
operations.push({operation that came from JSONPatcherProxy});
lastTimeout = setTimeout(sendOperations, 1, operations); |
What's the status of this? Is JSONPatcherProxy still sync? Any problems with it so far? |
Coming a bit late into this (we switched from PuppetJs to Palindrom just this week due to issues we had with migrating our code, not related to Palindrom though). Although quite elaborative, this post is about a potential draw-back with sync behavior. I found this thread because I noticed that patches are now sent over the network immediately when a change happens while patches used to be (with PuppetJs) collected in an event handler capturing mouse and keyboard events and thus multiple patches would be sent in a single request. I get that this has two main benefits:
The drawbacks I could see immediately however:
The second drawback is the main reason for posting this comment. I think an optional async behavior would be beneficial either by leaving it up to the client side application to trigger sending the patch queue, or send it in an event handler like PuppetJs did. The latter made total sense in PuppetJs, because one user interaction would result in a single round-trip to the server. If Palindrom can't assume there is a terminal connected (for e.g. NodeJs?), then leave it up to the application. I don't like the |
Imagine an API: Would this solve the problem without going async? |
@warpech : Yes! Perfect! As a side note, i just tried a workaround by updating a whole object in my view model, which will result in a single replace patch containing all the properties in the object. Works well from a Palindrom perspective, but Starcounter XSON chokes on it. It can't handle replace on an object property... I have a complex update scenario where this is much needed. The only other workaround I can come up with is to encode this complex scenario in a single string property instead of several. That'll work , but the view model will look more obscure. |
I tried going async in a branch. And didn't like it. I had to introduce a I agree with the transactional approach. It also gives us room for patch de-redundancy (for the lack of words). |
This is what I'll do for now. It has some other benefits too, and may be better for this use case after all. |
@warpech should I go for the |
Let's wait for @tomalec's opinion. @tomalec is this good enough as a replacement for Palindrom/Palindrom#29? Keep in mind that it is labeled "Nice to have", we don't have to it immediately. |
Thanks to
jsonpatch
all our apps assume that tree changes come asynchronously. So going synchronous is in fact the breaking change. We can leverage this and make JSONPatcherProxy asynchronous. Mind the fact that this will not create patches order problems! Because the changes are recorded synchronously and no change can go unnoticed. The asynchronous part only covers calling the callback (sending to the socket), the recording part remains synchronous.Pros:
WS.send
a lot. They will be batched into one patch.obj.size = 1; obj.size = 2
) would create two operations in the same patch, one of them is redundant. But we can compress them using my lib (I wrote it this weekend in my free time, I don't mind moving to Palindrom organisation if you agree to invest time in it).Cons:
Implementation:
instead of calling the callback with every change, we can:
Yup, that simple.
/cc @warpech @tomalec
The text was updated successfully, but these errors were encountered: