func (h *EventHandler) Add(target interface{}, eventName string, c EventCallback) {
	h.m.Lock()
	defer h.m.Unlock()
	if _, ok := h.cs[target]; !ok {
		h.cs[target] = make(map[string]map[int]EventCallback)
	}
	if _, ok := h.cs[target][eventName]; !ok {
		h.cs[target][eventName] = make(map[int]EventCallback)
	}
	h.idx++
	h.cs[target][eventName][h.idx] = c
}
Add adds a new callback for a specific target and event name
package astiencoder
import (
	"fmt"
	"sort"
	"sync"
	"github.com/asticode/go-astikit"
)
var (
	EventNameError             = "astiencoder.error"
	EventNameNodeContinued     = "astiencoder.node.continued"
	EventNameNodePaused        = "astiencoder.node.paused"
	EventNameNodeStarted       = "astiencoder.node.started"
	EventNameNodeStopped       = "astiencoder.node.stopped"
	EventNameStats             = "astiencoder.stats"
	EventNameWorkflowContinued = "astiencoder.workflow.continued"
	EventNameWorkflowPaused    = "astiencoder.workflow.paused"
	EventNameWorkflowStarted   = "astiencoder.workflow.started"
	EventNameWorkflowStopped   = "astiencoder.workflow.stopped"
	EventTypeContinued         = "continued"
	EventTypePaused            = "paused"
	EventTypeStarted           = "started"
	EventTypeStopped           = "stopped"
)
type Event struct {
	Name    string
	Payload interface{}
	Target  interface{}
}
func EventError(target interface{}, err error) Event {
	return Event{
		Name:    EventNameError,
		Payload: err,
		Target:  target,
	}
}
type EventHandler struct {
	cs  map[interface{}]map[string]map[int]EventCallback
	idx int
	m   *sync.Mutex
}
type EventCallback func(e Event) (deleteListener bool)
func NewEventHandler() *EventHandler {
	return &EventHandler{
		cs: make(map[interface{}]map[string]map[int]EventCallback),
		m:  &sync.Mutex{},
	}
}