-
Notifications
You must be signed in to change notification settings - Fork 191
feat: Add localeSignal() method to UI and VaadinSession #23367
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
base: main
Are you sure you want to change the base?
Conversation
Add a read-only signal that reflects the current locale and updates automatically when setLocale() is called. This allows components to reactively respond to locale changes using the signals API.
| */ | ||
| private Locale locale = Locale.getDefault(); | ||
|
|
||
| private transient ValueSignal<Locale> localeSignal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use case involves multiple UIs which according to our rules mean it should be a SharedValueSignal.
| @@ -127,6 +129,8 @@ public class UI extends Component | |||
|
|
|||
| private Locale locale = Locale.getDefault(); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we remove this field and always store the value in a signal instead of having two sources of truth?
Test Results1 146 files - 204 1 146 suites - 204 1h 11m 4s ⏱️ - 6m 8s For more details on these failures and errors, see this check. Results for commit 980cb29. ± Comparison against base commit 32fc241. This pull request removes 2231 and adds 12 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
- Change return type from Signal to WritableSignal for both UI and VaadinSession - Use SharedValueSignal for VaadinSession (thread-safe for multiple UIs) - Signal becomes source of truth once accessed via localeSignal() - Add effect in UI to notify LocaleChangeObservers on signal changes - Maintain backward compatibility when signals feature is not enabled
The signal now holds the locale value directly instead of mirroring a separate field. For VaadinSession, the locale field is retained only for serialization since SharedValueSignal is transient.
Document that writing directly to the signal does not trigger LocaleChangeObservers (UI) or propagate to UIs (VaadinSession).
|



Add a signal that reflects the current locale and updates automatically when setLocale() is called. This allows components to reactively respond to locale changes using the signals API.