event

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2017 License: GPL-2.0, GPL-3.0 Imports: 11 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Events map[string]*Event

Events contains the registered events in the application

View Source
var Templates map[string]*Event

Templates containes sample events as a preview to the user

Functions

func AddEvent

func AddEvent(event *Event) error

AddEvent adds an event to the application

func Register

func Register(trigger Core)

Register registers events as templates for the user

func RemoveEvent

func RemoveEvent(event *Event)

RemoveEvent removes an evenet from the application

Types

type Base

type Base struct {
	types.Triggerable `json:"-"`
}

Base is a struct used for subtyping to implement different events for the application

func (*Base) Bind

func (b *Base) Bind(event types.Triggerable)

Bind bind the trigger to the eventable

type Core

type Core interface {
	types.Triggerable
	Bind(e types.Triggerable)
	Describe() string
}

Core is an interfaces which is the trigger mechanism for an event

type Event

type Event struct {
	subject.Subject
	style.Style
	*sync.Mutex
	Core      `json:"-"`
	Observers []types.Runnable `json:"-"`
	UUID      string           `json:"uuid"`
	Desc      string           `json:"description"`
	Running   bool             `json:"running"`
	// contains filtered or unexported fields
}

Event is a type which is used to trigger tasks

func GetEventByID

func GetEventByID(id string) (*Event, error)

GetEventByID returns the event given by the id

func New

func New(trigger Core) *Event

New takes an event and applies its type. The same event is returned.

func (*Event) GenerateUUDI

func (e *Event) GenerateUUDI()

GenerateUUDI creates a new UUID for the event

func (*Event) ID

func (e *Event) ID() string

ID returns the unique id of the event

func (*Event) Start

func (e *Event) Start() error

Start starts the event for asynchronous listening

func (*Event) Stop

func (e *Event) Stop() error

Stop stops the event for listening

func (*Event) Subscribe

func (e *Event) Subscribe(task types.Runnable) error

Subscribe adds a new task to this event's observers

func (*Event) Trigger

func (e *Event) Trigger()

Trigger returns the trigger for the event

func (*Event) UnmarshalJSON

func (e *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON serialized an event fron json encoding

func (*Event) Unsubscribe

func (e *Event) Unsubscribe(task types.Runnable) error

Unsubscribe removes a task from this events observables

func (*Event) Validate

func (e *Event) Validate() error

Validate checks certain safety proper

type Proxy

type Proxy struct {
	*Event
}

Proxy is a eventable object with custom json mashal/unmarshal methods

func (*Proxy) MarshalJSON

func (p *Proxy) MarshalJSON() ([]byte, error)

MarshalJSON return the UUID of the event

func (*Proxy) UnmarshalJSON

func (p *Proxy) UnmarshalJSON(data []byte) error

UnmarshalJSON returns the event specified by it's id

Jump to

Keyboard shortcuts

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