package
3.0.0+incompatible
Repository: https://github.com/donutloop/toolkit.git
Documentation: pkg.go.dev

# README

Usage

Bus it is a simple but powerful publish-subscribe event system. It requires object to register themselves with the event bus to receive events.

Example

package main 

import (
	"github.com/donutloop/toolkit/bus"
	"log"
)

type msg struct {
	Id      int64
	counter int
}

func main() {
	b := bus.New()

    b.AddEventListener(func(m *msg) error {
        m.counter++
        return nil
    })

    b.AddEventListener(func(m *msg) error {
        m.counter++
        return nil
    })

    b.Publish(new(msg))
}