Skip to content

Commit

Permalink
Merge pull request #10 from lpetre/once_fix
Browse files Browse the repository at this point in the history
Make sure writing to the onces map is done with the lock
  • Loading branch information
chuckpreslar committed Apr 11, 2016
2 parents 560ea65 + 94d41b9 commit cbe5fe2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions emitter.go
Expand Up @@ -137,7 +137,11 @@ func (emitter *Emitter) Once(event, listener interface{}) *Emitter {
fn.Call(values)
}

// Lock before changing onces
emitter.Lock()
emitter.onces[fn] = reflect.ValueOf(run)
emitter.Unlock()

emitter.AddListener(event, run)
return emitter
}
Expand Down

0 comments on commit cbe5fe2

Please sign in to comment.