https://github.com/saromanov/goemits
Event emitter based on redis pubsub :hamster:
https://github.com/saromanov/goemits
emit events go redis
Last synced: 5 months ago
JSON representation
Event emitter based on redis pubsub :hamster:
- Host: GitHub
- URL: https://github.com/saromanov/goemits
- Owner: saromanov
- License: mit
- Created: 2015-06-24T17:15:14.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-04-07T08:12:32.000Z (about 5 years ago)
- Last Synced: 2025-04-10T13:13:57.896Z (about 1 year ago)
- Topics: emit, events, go, redis
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# goemits
[](http://godoc.org/github.com/saromanov/goemits)
[](https://goreportcard.com/report/github.com/saromanov/goemits)
[](https://travis-ci.org/saromanov/goemits) [](https://coveralls.io/r/saromanov/goemits?branch=master)
Event emitters based on pubsub in Redis.
```go
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
```go
emit.On("disconnect", "now")
```