Use mutex when doing a Store resync

This commit is contained in:
Lea Anthony
2021-01-27 06:03:17 +11:00
parent f7c2f12ab2
commit 56394ac50e
+6
View File
@@ -153,6 +153,9 @@ func (s *Store) setupListener() {
func (s *Store) resync() {
// Lock
s.mux.Lock()
// Stringify data
newdata, err := json.Marshal(s.data.Interface())
if err != nil {
@@ -162,6 +165,9 @@ func (s *Store) resync() {
}
}
// Lock
s.mux.Unlock()
// Emit event to front end
s.runtime.Events.Emit("wails:sync:store:updatedbybackend:"+s.name, string(newdata))