-
Notifications
You must be signed in to change notification settings - Fork 330
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
Support for page refreshes and broadcasting #499
Merged
Merged
Commits on Oct 27, 2023
-
Support for page refreshes and broadcasting
This PR is the Rails companion for the Turbo changes to add page refreshes. ```ruby turbo_refreshes_with scroll method: :morph, scroll: :preserve ``` This adds new Active Record helpers to broadcast page refreshes from models: ```ruby class Board broadcast_refreshes end ``` This works great in hierarchical structures, where child record touch parent records automatically to invalidate cache: ```ruby class Column belongs_to :board, touch: true # +Board+ will trigger a page refresh on column changes end ``` You can also specify the streamable declaratively: ```ruby class Column belongs_to :board broadcast_refreshes_to :board end ``` There are also instance-level companion methods to broadcast page refreshes: - `broadcast_refresh_later` - `broadcast_refresh_later_to(*streamables)` This PR introduces a new mechanism to suppress broadcasting of turbo treams for arbitrary blocks of code: ```ruby Recording.suppressing_turbo_broadcasts do ... end ``` When broadcasting page refreshes, the system will automatically debounce multiple calls in a row to only broadcast the last one. This is meant for scenarios where you process records in mass. Because of the nature of such signals, it makes no sense to broadcast them repeatedly and individually.
Configuration menu - View commit details
-
Copy full SHA for a9e011d - Browse repository at this point
Copy the full SHA a9e011dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b94462 - Browse repository at this point
Copy the full SHA 6b94462View commit details -
Configuration menu - View commit details
-
Copy full SHA for ddeeeb8 - Browse repository at this point
Copy the full SHA ddeeeb8View commit details
Commits on Oct 30, 2023
-
Configuration menu - View commit details
-
Copy full SHA for a669409 - Browse repository at this point
Copy the full SHA a669409View commit details
Commits on Oct 31, 2023
-
Debounce jobs to broadcast page refresh signals
A page refresh stream signals the need to reload the page. It's a global action that makes sense to aggregate when multiple signals are generated in a short period of time for a given streamable. This implementation is based on creating a thread-level debouncer associated to the set of streamables. The debouncer is implemented using concurrent-ruby's scheduled tasks.
Configuration menu - View commit details
-
Copy full SHA for 8fcc54b - Browse repository at this point
Copy the full SHA 8fcc54bView commit details
Commits on Nov 6, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 9d3fdeb - Browse repository at this point
Copy the full SHA 9d3fdebView commit details
Commits on Nov 13, 2023
-
Configuration menu - View commit details
-
Copy full SHA for a49f6a6 - Browse repository at this point
Copy the full SHA a49f6a6View commit details
Commits on Nov 14, 2023
-
Configuration menu - View commit details
-
Copy full SHA for d86dc96 - Browse repository at this point
Copy the full SHA d86dc96View commit details
Commits on Nov 16, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 57671f9 - Browse repository at this point
Copy the full SHA 57671f9View commit details -
Make wait noop if scheduled_task is nil
This can happen when the Debouncer has finished its work and we clear it from the current thread. The next call to refresh_debouncer_for creates a new Debouncer, but it doesn't have a scheduled_task yet. We only use the wait method in tests, to ensure that the debounces has finished its work. But if the scheduled_task is nil, we know that the debouncer has already finished its work.
Configuration menu - View commit details
-
Copy full SHA for 00b2b24 - Browse repository at this point
Copy the full SHA 00b2b24View commit details
Commits on Nov 17, 2023
-
Configuration menu - View commit details
-
Copy full SHA for b385276 - Browse repository at this point
Copy the full SHA b385276View commit details
Commits on Nov 20, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 1d6b6d3 - Browse repository at this point
Copy the full SHA 1d6b6d3View commit details
Commits on Nov 23, 2023
-
Configuration menu - View commit details
-
Copy full SHA for ec710c7 - Browse repository at this point
Copy the full SHA ec710c7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3199f7a - Browse repository at this point
Copy the full SHA 3199f7aView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.