Skip to content

Commit

Permalink
fix second subscribe on timescale
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kuzubov committed Aug 21, 2023
1 parent dbc220e commit aabd6dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sources/LightweightCharts/Implementations/API/TimeScale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ class TimeScale: JavaScriptObject {
return
}
let name = subscriberName(for: subscription)
let subscriberScript = subsriberScript(forName: name, subscription: subscription)
var subscriberScript = ""
if (activeSubscriptions[subscription] != .declared) {
subscriberScript = subsriberScript(forName: name, subscription: subscription)
context?.addMessageHandler(messageHandler, name: name)
}
let script = subscriberScript + "\n\(jsName).subscribe\(subscription.jsRepresentation)(\(name));"
context?.addMessageHandler(messageHandler, name: name)
context?.evaluateScript(script, completion: nil)
activeSubscriptions[subscription] = .active
}
Expand Down

0 comments on commit aabd6dc

Please sign in to comment.