Implement store.Push(k, op)

master
Bel LaPointe 2023-10-11 15:35:48 -06:00
parent caa0a8e0fa
commit d3ef13c4b4
2 changed files with 10 additions and 0 deletions

View File

@ -10,6 +10,16 @@ func NewStore() *Store {
return &store
}
func (store *Store) Push(k string, op Event) {
event, ok := store.Get(k)
if ok {
event = event.Push(op)
} else {
event = op
}
store.Set(k, event)
}
func (store *Store) Set(k string, v Event) {
(*sync.Map)(store).Store(k, v)
}