dispatch to main queue on set
This commit is contained in:
parent
bde740c9b4
commit
eef0df0930
|
@ -10,6 +10,7 @@ extension UserDefaults {
|
|||
}
|
||||
|
||||
func _set<Value: Defaults.Serializable>(_ key: String, to value: Value) {
|
||||
DispatchQueue.main.async { [self] in
|
||||
if (value as? _DefaultsOptionalProtocol)?._defaults_isNil == true {
|
||||
removeObject(forKey: key)
|
||||
return
|
||||
|
@ -17,6 +18,7 @@ extension UserDefaults {
|
|||
|
||||
set(Value.toSerializable(value), forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public subscript<Value: Defaults.Serializable>(key: Defaults.Key<Value>) -> Value {
|
||||
get { _get(key.name) ?? key.defaultValue }
|
||||
|
|
Loading…
Reference in New Issue