File tree 2 files changed +52
-4
lines changed
Sources/OpenSwiftUI/Core/Update
Tests/OpenSwiftUICompatibilityTests/View/Modifier
2 files changed +52
-4
lines changed Original file line number Diff line number Diff line change @@ -71,9 +71,24 @@ enum Update {
71
71
72
72
@inline ( __always)
73
73
static func dispatchActions( ) {
74
- // FIXME
75
- for action in actions {
76
- action ( )
74
+ guard !actions. isEmpty else {
75
+ return
76
+ }
77
+
78
+ let actions = Update . actions
79
+ Update . actions = [ ]
80
+ performOnMainThread {
81
+ // TODO: Signpost.postUpdateActions
82
+ begin ( )
83
+ for action in actions {
84
+ let oldDepth = depth
85
+ action ( )
86
+ let newDepth = depth
87
+ if newDepth != oldDepth {
88
+ fatalError ( " Action caused unbalanced updates. " )
89
+ }
90
+ }
91
+ end ( )
77
92
}
78
93
}
79
94
@@ -107,5 +122,5 @@ extension Update {
107
122
// FIXME: migrate to use @_extern(c, "xx") in Swift 6
108
123
extension MovableLock {
109
124
@_silgen_name ( " _MovableLockSyncMain " )
110
- static func syncMain( lock: MovableLock , body: @escaping ( ) -> Void )
125
+ static func syncMain( lock: MovableLock , body: @escaping ( ) -> Void )
111
126
}
Original file line number Diff line number Diff line change
1
+ //
2
+ // AppearanceActionModifierTests.swift
3
+ // OpenSwiftUICompatibilityTests
4
+
5
+ import Testing
6
+
7
+ #if canImport(Darwin)
8
+ struct AppearanceActionModifierTests {
9
+ @Test
10
+ func appear( ) async throws {
11
+ struct ContentView : View {
12
+ var confirmation : Confirmation
13
+
14
+ var body : some View {
15
+ AnyView ( EmptyView ( ) )
16
+ . onAppear {
17
+ confirmation ( )
18
+ }
19
+ }
20
+ }
21
+
22
+ #if os(iOS)
23
+ await confirmation { @MainActor confirmation in
24
+ let vc = UIHostingController ( rootView: ContentView ( confirmation: confirmation) )
25
+ vc. triggerLayout ( )
26
+ workaroundIssue87 ( vc)
27
+ }
28
+ #endif
29
+ }
30
+
31
+ // TODO: Add disappear support and test case
32
+ }
33
+ #endif
You can’t perform that action at this time.
0 commit comments