events

package
v0.0.0-...-4502c18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2018 License: GPL-3.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Push

func Push(title string, e Eventer)

Subscribe push to default EventListener.

func PushBytes

func PushBytes(title string, bytes []byte)

Subscribe push bytes to default EventListener.

func SetEventListener

func SetEventListener(el *EventListener)

SetEventListener sets default EventListener (without instance).

func Subscribe

func Subscribe(title string) chan Eventer

Subscribe subscribes to default EventListener.

Types

type Event

type Event struct {
	// contains filtered or unexported fields
}

Event is default event implementation.

func (*Event) GetBytes

func (e *Event) GetBytes() []byte

GetBytes gets bytes from the event.

func (*Event) GetObject

func (e *Event) GetObject(obj interface{}) error

func (*Event) SetBytes

func (e *Event) SetBytes(bytes []byte) int

SetBytes sets bytes to the event.

type EventListener

type EventListener struct {
	// contains filtered or unexported fields
}

EventListener sends out certain events to their subscribers.

func NewEventListener

func NewEventListener() *EventListener

NewEventListener creates event listener.

func (*EventListener) Push

func (el *EventListener) Push(title string, e Eventer)

Push sends a new event to its subscribers.

func (*EventListener) PushBytes

func (el *EventListener) PushBytes(title string, bytes []byte)

PushBytes converts bytes to an event and executes Push

func (*EventListener) Subscribe

func (el *EventListener) Subscribe(title string) chan Eventer

Subscribe creates a new chan and signs it for news, then returns.

type Eventer

type Eventer interface {
	// GetBytes gets bytes from the event.
	GetBytes() []byte

	// SetBytes sets bytes to the event.
	SetBytes([]byte) int

	// Get gets object
	GetObject(obj interface{}) error
}

Eventer is interface that defines an object that can be perceived as an event.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL