Closed tabatkins closed 1 year ago
The only downside to this is it might be confusing to access the value getting null and then having to look up some other way to get the UA value?
But having said that using matchMedia as the encouraged way to actually use these values is probably fine.
Yeah, see #6 about how this would interact with the async nature of saving/retrieving from durable storage, so getting a null
to mean just "this hasn't been overridden" seems okay to me.
At the moment, the suggested API shape makes the PreferenceManager vaguely Map-like - you have
get()
/setOverride()
/clearOverride()
. But Maps are useful when the key space is open-ended, and that's not the case here: we have a fixed set of override names (which can change from version to version, but are closed for any given browser version.I suggest we just define all the overrides as attributes on
PreferenceManager
, so you could write likenavigator.preferences.colorScheme = "dark";
. Then we can removeget()
andset()
. We could even removeclear()
if we define that they're nullable.(
getSupported()
giving you the allowed values is still useful, we should keep it.)