package engine import ( "github.com/imkira/go-observer" "sirlab.de/go/knyt/syncdata" "time" ) func NewEngine() *Engine { engine := Engine{ versionRef: 0, obs: observer.NewProperty(syncdata.SyncData{}), notify: make(chan bool, 2), } return &engine } func (eng *Engine) Run(populateSyncDataCb PopulateSyncDataCb) { for { select { case <-eng.notify: // nop case <-time.After(15 * time.Second): // nop } eng.publish(populateSyncDataCb) } } func (eng *Engine) Update() { eng.notify <- true }