Rework access to ThemeRegistry
global (#7023)
This PR reworks how we access the `ThemeRegistry` global.
Previously we were making calls directly on the context, like
`cx.global::<ThemeRegistry>`. However, one problem with this is that it
spreads out the knowledge of exactly what type is stored in the global.
In order to make it easier to adjust the type we store in the context
(e.g., wrapping the `ThemeRegistry` in an `Arc`), we now call methods on
the `ThemeRegistry` itself for accessing the global.
It would also be interesting to see how we could prevent access to the
`ThemeRegistry` without going through one of these dedicated methods 🤔
Release Notes:
- N/A
This commit is contained in:
parent
2a2cf45e90
commit
7656096814
5 changed files with 24 additions and 8 deletions
|
@ -71,7 +71,7 @@ fn main() {
|
|||
|
||||
let selector = story_selector;
|
||||
|
||||
let theme_registry = cx.global::<ThemeRegistry>();
|
||||
let theme_registry = ThemeRegistry::global(cx);
|
||||
let mut theme_settings = ThemeSettings::get_global(cx).clone();
|
||||
theme_settings.active_theme = theme_registry.get(&theme_name).unwrap();
|
||||
ThemeSettings::override_global(theme_settings, cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue