First off let me start of saying that I like the changes you've made recently it helps clean things up and make the code more maintainable.
I have a property wrapper that wraps UserDefaults. And before I had Combine as a way to listen to changes, via CurrentValueSubject, on UserDefaults. Since I'm in the process of removing Combine and using strictly AsyncSequence I started using CurrentValue version.
@propertyWrapper
public struct Defaults<T: Codable> {
private let key: String
public let currentValue: AsyncStreams.CurrentValue<T>
public var projectedValue: Defaults<T> { self }
public var wrappedValue: T {
get { currentValue.element } <-- Here is my problem
set {
currentValue.send(newValue) <-- Here is my problem
userDefaults.set(object: newValue, forKey: key)
}
}
public init(wrappedValue defaultValue: T, _ key: String) {
self.key = key
self.currentValue = AsyncStreams.CurrentValue<T>(defaultValue)
self.wrappedValue = userDefaults.object(T.self, with: key) ?? defaultValue
}
}
element property now requires I use async/await here. My question is ...
Do you know how I can resolve this and still meet the property wrappers need for wrappedValue?
First off let me start of saying that I like the changes you've made recently it helps clean things up and make the code more maintainable.
I have a property wrapper that wraps UserDefaults. And before I had Combine as a way to listen to changes, via CurrentValueSubject, on UserDefaults. Since I'm in the process of removing Combine and using strictly AsyncSequence I started using CurrentValue version.
element
property now requires I use async/await here. My question is ... Do you know how I can resolve this and still meet the property wrappers need for wrappedValue?Thanks!