Event emitters based on pubsub in Redis.
package main
import (
"fmt"
"github.com/saromanov/goemits"
)
func main() {
emit := goemits.New(goemits.Config{
RedisAddress: "127.0.0.1:6379",
})
emit.On("connect", func(message interface{}) {
fmt.Println("Found: ", message)
emit.Emit("disconnect", "data")
})
emit.On("disconnect", func(message interface{}) {
fmt.Println("Disconnect")
emit.Quit()
})
emit.OnAny(func(message interface{}) {
//This get any events
})
emit.Start()
}
Emit of the event
emit.On("disconnect", "now")