Closed mac-gallagher closed 1 year ago
Another weird thing is that the Defaults.publisher
gets triggered whenever I set a new value to massUnit
, but the change
property has the same unit for both newValue
and oldValue
Defaults.publisher(.massUnit)
.sink { change in
print(change.oldValue) // grams
print(change.newValue) // grams
}
Discovered the root cause! It was related to UserDefaults
not immediately writing to disk, I wasn't aware there was a delay :)
Hi @sindresorhus + all 👋
I've been trying to write a custom type to encode/decode
Dimension
(superclass of the various measurement units e.g.UnitTemperature
,UnitMass
). In my bridge, I'm relying on the fact that aDimension
is uniquely defined by itssymbol
:However, this is what I'm seeing in practice
If using a default value like
this is what I see
Any idea what's going wrong here? I stepped through its breakpoints and my implementation seems to be working fine, but the
Defaults
don't seem to be getting updated? 🤔Thanks for the help in advance! Mac