Use async/await for JavaScript-backed reads
masterAll JavaScript-backed read operations that previously used completion handlers are now async throws(JavaScriptBridgeError) APIs. You should wrap these calls in a Task { @MainActor in ... } block when interacting with the chart from a view controller to ensure UI safety and proper error handling.
Task { @MainActor in
do {
let panes = try await chart.panes()
let visibleRange = try await chart.timeScale().getVisibleRange()
let formatted = try await series.priceFormatter().format(price: 42)
print("Pane count:", panes.count)
print(visibleRange.from)
print(formatted)
} catch let error as JavaScriptBridgeError {
print("Bridge error:", error)
} catch {
print("Unexpected error:", error)
}
}