Enable async/await in DOM Fiber renderer (#516)

I noticed that Tasks weren't running when using the Fiber renderer. I'm
not sure this is the appropriate place, but the normal DOM renderer
calls `installGlobalExecutor` in it's `init`, so I just mirrored that.
This commit is contained in:
Lukas 2022-10-02 21:36:29 +02:00 committed by GitHub
parent af810902bd
commit 56822c906b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,7 @@
//
import Foundation
import JavaScriptEventLoop
import JavaScriptKit
import OpenCombineJS
import OpenCombineShim
@ -97,6 +98,10 @@ public struct DOMFiberRenderer: FiberRenderer {
}
public init(_ rootSelector: String, useDynamicLayout: Bool = true) {
if #available(macOS 10.15, *) {
JavaScriptEventLoop.installGlobalExecutor()
}
guard let reference = document.querySelector!(rootSelector).object else {
fatalError("""
The root element with selector '\(rootSelector)' could not be found. \