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