kataras / go-events

:mega: Pure nodejs EventEmmiter for the Go Programming Language.
MIT License
98 stars 15 forks source link

Fix map race condition in Emit #5

Closed plorenz closed 4 years ago

plorenz commented 4 years ago

This fixes the race condition in Emit. Because Emit now read locks the map I also had to change Once so that it doesn't deadlock. If you don't like the remove in a separate go-routine, another option would be check for the oneTime type in Emit and remove it at the end.

kataras commented 4 years ago

Thanks @plorenz looks OK for the use case it's designed, please feel free to make any further improvements in the future.