ToastService: Add default options & methods for setting/getting default options#8384
Open
pilotkid wants to merge 1 commit intoprimefaces:masterfrom
Open
ToastService: Add default options & methods for setting/getting default options#8384pilotkid wants to merge 1 commit intoprimefaces:masterfrom
pilotkid wants to merge 1 commit intoprimefaces:masterfrom
Conversation
|
I like this idea. I find it very helpful to minimize the amount of repeated code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add default options support to ToastService
This PR adds support for default toast options, reducing repetition (e.g. always setting
life) while remaining fully backwards compatible.Impact
ToastServiceDoc.vueWhy
Today users must repeat common options on every toast:
This is repetitive and makes global consistency harder.
What’s changed
Install-time defaults
You can now pass defaults (supports all toastMessage parameters) when installing the service:
Runtime APIs
Two new methods are available on the toast service:
Merges the provided options into the current defaults (shallow merge). Useful for dynamically adjusting behavior (for example: changing toast duration based on end user's preferences).
Returns the current default options.
Merge behavior
Each toast message is shallow-merged with defaults:
Old vs New Usage
Before (still supported)
After (with defaults)
Sorry for the longer description. I understand this may be considered a feature request, but it’s something I care about and believe offers a real DX improvement with very minimal impact. I added extra context to make the intent and scope clear, in case that helps with review or inspires a similar implementation by the core team.