Skip to content

Commit 18237c0

Browse files
committed
Add UIHostingVIew.beginTransaction
1 parent e6300d9 commit 18237c0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/OpenSwiftUI/Integration/Hosting/UIKit/View/UIHostingView+Extension.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public import UIKit
1010
@_spi(ForOpenSwiftUIOnly)
1111
@_spi(Private)
1212
public import OpenSwiftUICore
13+
import COpenSwiftUI
1314

1415
// MARK: - _UIHostingView + UIViewControllerProvider
1516

@@ -196,7 +197,21 @@ extension _UIHostingView: ViewRendererHost {
196197
@available(OpenSwiftUI_v6_0, *)
197198
public func beginTransaction() {
198199
onMainThread { [weak self] in
199-
// TODO: UIKitUpdateCycle
200+
guard UIKitUpdateCycle.defaultUseSetNeedsLayout else {
201+
let updateAction = {
202+
Update.ensure {
203+
_ = self?.updateGraph {
204+
$0.flushTransactions()
205+
}
206+
}
207+
}
208+
if _UIUpdateCycleEnabled() {
209+
UIKitUpdateCycle.addPreCommitObserver(updateAction)
210+
}
211+
RunLoop.addObserver(updateAction)
212+
return
213+
}
214+
self?.base.requestImmediateUpdate()
200215
}
201216
}
202217

0 commit comments

Comments
 (0)