[Feature] Add pagination hook method #3632
Merged
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.
This PR adds a stub method to the pagination trait as a hook that users can override if they need any side effects to happen when pagination changes. For example, they may want to fire off a browser event, so they can tell the browser to scroll to the top on pagination changed.
Rather than Livewire firing off browser events that may not get used, this hook method instead lets the developer decide how they want to handle it.
I have named the method
paginationPageChanged
and it accepts the page the pagination has changed to as a property.For example, this could be put into a component with pagination, to fire off a browser event.
I intentionally made it this method name to ensure the risk of a collision with an existing method name like this is minimal.
Another option would be to use the existing updating/updated convention and call it something like
updatedPaginationPage
.Hope this helps!