Skip to content

Commit

Permalink
Enable async/await in DOM Fiber renderer (#516)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ahti authored Oct 2, 2022
1 parent af81090 commit 56822c9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/TokamakDOM/DOMFiberRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//

import Foundation
import JavaScriptEventLoop
import JavaScriptKit
import OpenCombineJS
import OpenCombineShim
Expand Down Expand Up @@ -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. \
Expand Down

0 comments on commit 56822c9

Please sign in to comment.