Commit 3d98a76 1 parent a6fc06a commit 3d98a76 Copy full SHA for 3d98a76
File tree 3 files changed +8
-4
lines changed
3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ extension Defaults {
285
285
286
286
continuation. onTermination = { _ in
287
287
// `invalidate()` should be thread-safe, but it is not in practice.
288
- DispatchQueue . main . async {
288
+ Task { @ MainActor in
289
289
observation. invalidate ( )
290
290
}
291
291
}
@@ -334,7 +334,7 @@ extension Defaults {
334
334
335
335
continuation. onTermination = { _ in
336
336
// `invalidate()` should be thread-safe, but it is not in practice.
337
- DispatchQueue . main . async {
337
+ Task { @ MainActor in
338
338
for observation in immutableObservations {
339
339
observation. invalidate ( )
340
340
}
@@ -378,7 +378,7 @@ extension Defaults {
378
378
379
379
continuation. onTermination = { _ in
380
380
// `invalidate()` should be thread-safe, but it is not in practice.
381
- DispatchQueue . main . async {
381
+ Task { @ MainActor in
382
382
for observation in observations {
383
383
observation. invalidate ( )
384
384
}
Original file line number Diff line number Diff line change @@ -75,8 +75,9 @@ Access stored values from SwiftUI.
75
75
76
76
This is similar to `@AppStorage` but it accepts a ``Defaults/Key`` and many more types.
77
77
*/
78
+ @MainActor
78
79
@propertyWrapper
79
- public struct Default < Value: Defaults . Serializable > : DynamicProperty {
80
+ public struct Default < Value: Defaults . Serializable > : @ preconcurrency DynamicProperty {
80
81
@_documentation ( visibility: private)
81
82
public typealias Publisher = AnyPublisher < Defaults . KeyChange < Value > , Never >
82
83
@@ -254,8 +255,10 @@ extension Defaults.Toggle {
254
255
}
255
256
}
256
257
258
+ @MainActor
257
259
@propertyWrapper
258
260
private struct ViewStorage < Value> : DynamicProperty {
261
+ @MainActor
259
262
private final class ValueBox {
260
263
var value : Value
261
264
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ final class DefaultsSwiftUITests {
41
41
Defaults . removeAll ( suite: suite_)
42
42
}
43
43
44
+ @MainActor
44
45
@Test
45
46
func testSwiftUIObserve( ) {
46
47
let view = ContentView ( )
You can’t perform that action at this time.
0 commit comments