indicator/rsi: make update callback field private

This commit is contained in:
c9s 2022-07-14 01:18:55 +08:00
parent b2538b6960
commit 8d8d9a7c59
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 3 additions and 3 deletions

View File

@ -22,7 +22,7 @@ type RSI struct {
PreviousAvgGain float64 PreviousAvgGain float64
EndTime time.Time EndTime time.Time
UpdateCallbacks []func(value float64) updateCallbacks []func(value float64)
} }
func (inc *RSI) Update(price float64) { func (inc *RSI) Update(price float64) {

View File

@ -5,11 +5,11 @@ package indicator
import () import ()
func (inc *RSI) OnUpdate(cb func(value float64)) { func (inc *RSI) OnUpdate(cb func(value float64)) {
inc.UpdateCallbacks = append(inc.UpdateCallbacks, cb) inc.updateCallbacks = append(inc.updateCallbacks, cb)
} }
func (inc *RSI) EmitUpdate(value float64) { func (inc *RSI) EmitUpdate(value float64) {
for _, cb := range inc.UpdateCallbacks { for _, cb := range inc.updateCallbacks {
cb(value) cb(value)
} }
} }