Jun10ng / goeventbus

a simple event bus in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What

a simple event bus in golang

Use

	bus := NewBus()
	sub := NewSub()

	bus.Subscribe("topic1", sub)

	go func() {
		msg := sub.Out().(int)
		if msg != 7 {
			t.Fatalf("got wrong number:%d", msg)
		}
	}()
	bus.Publish("topic1", 7)
	// or use PubFunc to publish to a certain topic
	pubFunc := bus.PubFunc("topic1")
	pubFunc(7)

For more details,see testfile

About

a simple event bus in golang


Languages

Language:Go 100.0%