weather-api/weathersource/weather-source-base.go
2021-08-22 13:05:03 +02:00

20 lines
796 B
Go

package weathersource
import "weather-data/storage"
//WeatherSourceBase is the lowlevel-implementation of the WeatherSource interface, intended to used by highlevel-implementations
type WeatherSourceBase struct {
newWeatherDataCallbackFuncs []NewWeatherDataCallbackFunc
}
//AddNewWeatherDataCallback adds a new callbackMethod for incoming weather data
func (source *WeatherSourceBase) AddNewWeatherDataCallback(callback NewWeatherDataCallbackFunc) {
source.newWeatherDataCallbackFuncs = append(source.newWeatherDataCallbackFuncs, callback)
}
//NewWeatherData executes all newWeatherDataCallbackFuncs for this datapoint
func (source *WeatherSourceBase) NewWeatherData(datapoint storage.WeatherData) {
for _, callback := range source.newWeatherDataCallbackFuncs {
callback(datapoint)
}
}