cable_ready icon indicating copy to clipboard operation
cable_ready copied to clipboard

Server debounce updates

Open leastbad opened this issue 4 years ago • 0 comments

This is respectfully proposed as a server-side alternative to https://github.com/stimulusreflex/cable_ready/pull/151.

It occurred to me that the real problem we're trying to solve is not receiving updates too quickly, but sending updates too quickly.

To address the disease and not the symptom, I used the debouncer gem to wrap the ActionCable call. It works similarly to the much more familiar JS debouncers that we're familiar with, but because it's Ruby, creates threads.

What I don't know is whether I got my isolation right. I made use of the grouping mechanism of the debouncer gem to treat each identifier as a group. This was reasonably straight-forward for the model callbacks, but in the case of the collection callbacks, I created a class method called cable_ready_debouncer which memoizes an instance of Debouncer.

I think I got it right, but a sanity check would be really appreciated!

leastbad avatar Sep 30 '21 09:09 leastbad