This is package implements pattern-observer
import (
"github.com/agoalofalife/event"
)
func main() {
// create struct
e := event.New()
// subscriber
e.Add("push.email", func(text string){
// some logic
}, "text")
// init event
e.Fire("push.email") // or e.Go("push.email")
}
let us consider an example:
type Email struct {
count int
}
func (e *Email) Push() {
e.count += 1
fmt.Printf("Push email again, count %d \n", e.count)
}
func main() {
e := event.New()
email := new(Email)
e.Add(email, email.Push)
e.Fire(email)
e.Fire(email)
}
// output
// Push email again, count 1
// Push email again, count 2
Read more information in examples :+1:
$ claude mcp add event \
-- python -m otcore.mcp_server <graph>