package eventemitter

import "github.com/Diarkis/diarkis/eventemitter"

Index

Types

type EventEmitter

type EventEmitter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

EventEmitter represents the event emitter.

func New

func New(name string) *EventEmitter

New creates a new event emitter

func (*EventEmitter) Emit

func (emitter *EventEmitter) Emit(eventName string, params interface{})

Emit triggers an event and invokes the callbacks

func (*EventEmitter) On

func (emitter *EventEmitter) On(eventName string, callback func(interface{}))

On assigns a callback to an event

func (*EventEmitter) Remove

func (emitter *EventEmitter) Remove(eventName string, callback func(interface{})) bool

Remove deletes a callback assigned to the given event.

[IMPORTANT] The callback passed is the callback to be removed.