Tweaks
This commit is contained in:
parent
a6fc06aa1b
commit
3d98a76aab
|
@ -285,7 +285,7 @@ extension Defaults {
|
|||
|
||||
continuation.onTermination = { _ in
|
||||
// `invalidate()` should be thread-safe, but it is not in practice.
|
||||
DispatchQueue.main.async {
|
||||
Task { @MainActor in
|
||||
observation.invalidate()
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ extension Defaults {
|
|||
|
||||
continuation.onTermination = { _ in
|
||||
// `invalidate()` should be thread-safe, but it is not in practice.
|
||||
DispatchQueue.main.async {
|
||||
Task { @MainActor in
|
||||
for observation in immutableObservations {
|
||||
observation.invalidate()
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ extension Defaults {
|
|||
|
||||
continuation.onTermination = { _ in
|
||||
// `invalidate()` should be thread-safe, but it is not in practice.
|
||||
DispatchQueue.main.async {
|
||||
Task { @MainActor in
|
||||
for observation in observations {
|
||||
observation.invalidate()
|
||||
}
|
||||
|
|
|
@ -75,8 +75,9 @@ Access stored values from SwiftUI.
|
|||
|
||||
This is similar to `@AppStorage` but it accepts a ``Defaults/Key`` and many more types.
|
||||
*/
|
||||
@MainActor
|
||||
@propertyWrapper
|
||||
public struct Default<Value: Defaults.Serializable>: DynamicProperty {
|
||||
public struct Default<Value: Defaults.Serializable>: @preconcurrency DynamicProperty {
|
||||
@_documentation(visibility: private)
|
||||
public typealias Publisher = AnyPublisher<Defaults.KeyChange<Value>, Never>
|
||||
|
||||
|
@ -254,8 +255,10 @@ extension Defaults.Toggle {
|
|||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@propertyWrapper
|
||||
private struct ViewStorage<Value>: DynamicProperty {
|
||||
@MainActor
|
||||
private final class ValueBox {
|
||||
var value: Value
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ final class DefaultsSwiftUITests {
|
|||
Defaults.removeAll(suite: suite_)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test
|
||||
func testSwiftUIObserve() {
|
||||
let view = ContentView()
|
||||
|
|
Loading…
Reference in New Issue