Skip to content

saromanov/goemits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goemits

Documentation Go Report Card Build Status Coverage Status

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

About

Event emitter based on redis pubsub 🐹

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages