Our app has many-to-many relationships which I manage with a join table. The front-end uses React/Redux and we use optimistic updates. That way if the user does something like re-order a list of 100 items, the UI doesn’t have to wait for the server to respond in order to show the user that the re-ordering worked.
I’m trying to implement LiveQuery so that if a user modifies something (say by re-ordering a list) then any other logged in user can see that updated reflected in their UI without refreshing the page. Or if the user has multiple windows open all looking at the same screen they automatically update to reflect the changes they made.
But with LiveQuery a client receives events even about updates made by that client. This can cause an issue if the user makes multiple updates in succession. For example:
- User re-orders a list (updated in Redux) and the client updates are pushed to the server
- User re-orders the list again (updated in Redux), pushing more updates to the server
- LiveQuery triggers an event from update (1) which reverts the Redux update from (2)
- LiveQuery triggers an event from update (2), which brings Redux back in line with (2)
This would create a pretty bad user experience.
So is there a way to ignore any events that were caused by the current client?