Skip to content

Commit 7483b1d

Browse files
committed
add comments and remove logs
1 parent 336d566 commit 7483b1d

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

src/app/leverage/utils/datafeed.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Template pulled from https://github.com/cctdaniel/pyth-tv-charting-lib/blob/6adfdfcd0c4cf9c503ab154d4d4570a634a0ddbe/src/utils/datafeed.js
12
import {
23
subscribeOnStream,
34
unsubscribeFromStream,
@@ -23,7 +24,6 @@ const getPriceScale = (symbol: string) => {
2324

2425
const datafeed = {
2526
onReady: (callback: any) => {
26-
console.log('[onReady]: Method call')
2727
fetch(`${API_ENDPOINT}/config`).then((response) => {
2828
response.json().then((configurationData) => {
2929
setTimeout(() => callback(configurationData))
@@ -36,7 +36,6 @@ const datafeed = {
3636
symbolType: any,
3737
onResultReadyCallback: any,
3838
) => {
39-
console.log('[searchSymbols]: Method call')
4039
fetch(`${API_ENDPOINT}/search?query=${userInput}`).then((response) => {
4140
response.json().then((data) => {
4241
onResultReadyCallback(data)
@@ -87,7 +86,6 @@ const datafeed = {
8786
onErrorCallback: any,
8887
) => {
8988
const { from, to, firstDataRequest } = periodParams
90-
console.log('[getBars]: Method call', symbolInfo, resolution, from, to)
9189

9290
const maxRangeInSeconds = 365 * 24 * 60 * 60 // 1 year in seconds
9391

@@ -140,10 +138,6 @@ const datafeed = {
140138
subscriberUID: any,
141139
onResetCacheNeededCallback: any,
142140
) => {
143-
console.log(
144-
'[subscribeBars]: Method call with subscriberUID:',
145-
subscriberUID,
146-
)
147141
subscribeOnStream(
148142
symbolInfo,
149143
resolution,
@@ -154,10 +148,6 @@ const datafeed = {
154148
)
155149
},
156150
unsubscribeBars: (subscriberUID: any) => {
157-
console.log(
158-
'[unsubscribeBars]: Method call with subscriberUID:',
159-
subscriberUID,
160-
)
161151
unsubscribeFromStream(subscriberUID)
162152
},
163153
}

src/app/leverage/utils/streaming.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Assuming you're working in a browser environment that supports fetch and ReadableStream
1+
// Template pulled from https://github.com/cctdaniel/pyth-tv-charting-lib/blob/6adfdfcd0c4cf9c503ab154d4d4570a634a0ddbe/src/utils/streaming.js
22
const streamingUrl =
33
'https://benchmarks.pyth.network/v1/shims/tradingview/streaming'
44
const channelToSubscription = new Map()
@@ -35,7 +35,6 @@ function handleStreamingData(data: any) {
3535
low: Math.min(lastDailyBar.low, tradePrice),
3636
close: tradePrice,
3737
}
38-
console.log('[stream] Update the latest bar by price', tradePrice)
3938
}
4039

4140
subscriptionItem.lastDailyBar = bar
@@ -98,7 +97,6 @@ function startStreaming(retries = 3, delay = 3000) {
9897
})
9998
function attemptReconnect(retriesLeft: any, delay: any) {
10099
if (retriesLeft > 0) {
101-
console.log(`[stream] Attempting to reconnect in ${delay}ms...`)
102100
setTimeout(() => {
103101
startStreaming(retriesLeft - 1, delay)
104102
}, delay)
@@ -135,10 +133,6 @@ export function subscribeOnStream(
135133
handlers: [handler],
136134
}
137135
channelToSubscription.set(channelString, subscriptionItem)
138-
console.log(
139-
'[subscribeBars]: Subscribe to streaming. Channel:',
140-
channelString,
141-
)
142136

143137
// Start streaming when the first subscription is made
144138
startStreaming()
@@ -154,10 +148,6 @@ export function unsubscribeFromStream(subscriberUID: any) {
154148

155149
if (handlerIndex !== -1) {
156150
// Unsubscribe from the channel if it is the last handler
157-
console.log(
158-
'[unsubscribeBars]: Unsubscribe from streaming. Channel:',
159-
channelString,
160-
)
161151
channelToSubscription.delete(channelString)
162152
break
163153
}

0 commit comments

Comments
 (0)