Skip to content
generated from shahariaazam/go-pkg

Library to implement event listener in Golang app

License

Notifications You must be signed in to change notification settings

shaharia-lab/gevli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gevli

Implementing Event Listener for Golang Application





Usage

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)
}

Documentation

Full documentation is available on pkg.go.dev/github.com/shahariaazam/gevli

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Library to implement event listener in Golang app

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages