README (438B)
1 Tiny event emitter for Go. 2 3 ## Install 4 5 ``` 6 go get go.lair.cx/eve 7 ``` 8 9 ## Usage 10 11 ```go 12 type SomeEvent struct{} 13 14 type App struct { 15 // ... 16 17 OnSomething eve.Event[*SomeEvent] 18 } 19 20 func main() { 21 app := &App{} 22 23 app.OnSomething.On(func(ctx context.Context, e *SomeEvent) error { 24 fmt.Println("Something happened!") 25 return nil 26 }) 27 28 err := app.OnSomething.Emit(context.Background(), &SomeEvent{}) 29 if err != nil { 30 // Handle err 31 } 32 } 33 ``` 34