Implementing Event Listener for Golang Application
go get go get github.com/shahariaazam/gevli
And start using like -
package main
import (
"fmt"
"github.com/shahariaazam/gevli"
)
func main() {
emitter := gevli.NewEventEmitter()
// Add listener for "message" event.
emitter.AddListener("message", func(event gevli.Event) {
fmt.Println("Message received:", event.Data)
})
// Add listener for "ping" event.
emitter.AddListener("ping", func(event gevli.Event) {
fmt.Println("Ping received:", event.Data)
})
// Emit "message" event.
emitter.EmitSync("message", "Hello, world!")
// Emit "ping" event.
emitter.Emit("ping", nil)
}
Full documentation is available on pkg.go.dev/github.com/shahariaazam/gevli
This project is licensed under the MIT License - see the LICENSE file for details.