Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Page Refreshes #128

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

Merged
merged 38 commits into from
Nov 23, 2023
Merged

Page Refreshes #128

merged 38 commits into from
Nov 23, 2023

Conversation

tonysm
Copy link
Collaborator

@tonysm tonysm commented Nov 5, 2023

Added

  • Adds a new <x-turbo-refreshes-with method="morph" scroll="preserve" /> Blade component that can be used in layouts/pages to toggle on and off the page refresh behavior
  • Adds a new broadcastRefreshes property that can be toggled on a model that uses the Broadcasts trait. This will auto-wire the page refresh broadcasts for the current model. When the model was recently created, it dispatches it to the model's plural name by default (private-messages for a App\Models\Message model). Otherwise, it will automatically send the page refresh broadcasts to the current model's channel (private-App.Models.Message.1 for App\Models\Message with ID of 1)
  • Adds a new broadcastRefreshesTo property that can be toggled on a model that uses the Broadcasts trait. This will also auto-wire the page refresh broadcasts for the current model, but it will send the page refresh broadcasts to the streamable(s) defined in the property (usually a relationship)
  • Adds new recede, resume, and refresh assertion macros to the TestResponse class
  • Adds a way to suppress broadcasting to avoid sending them on a specific callback/scope

closes #126


Pending:

  • Pass the Turbo Tracking Request ID in the page refresh broadcasts (should it also be sent on any other broadcasts too?)
  • Add a debouncing mechanism to avoid sending multiple page refreshes to the same model within the same request in a short interval (this can happen when updating multiple models within the same request and using model touching, for instance. The idea is that if multiple page refreshes are triggered to same model within 500ms in the same request/scope, we should only send 1)
  • Add a suppression mechanism so we can have a way to disable broadcasts if we want to (similar to Model::withoutTouching(fn), so similarly to the withoutTouching(fn) it should also allow suppressing broadcasts for specific models)
  • Documentation

@tonysm
Copy link
Collaborator Author

tonysm commented Nov 11, 2023

Looks complete (at least in feature parity with turbo-rails). Waiting for them to merge theirs so I can merge this one.

@tonysm tonysm marked this pull request as ready for review November 23, 2023 22:11
@tonysm tonysm merged commit 33ebbde into 2.x Nov 23, 2023
@tonysm tonysm deleted the page-refreshes branch November 23, 2023 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for page refreshes & broadcasting
1 participant