events

package
v0.0.0-...-040c84b Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name     string
	EntityID string
	Payload  interface{}
}

Event holds data on system and domain events

type Evented

type Evented struct {
	Events    []Event
	Observers []Observer
}

Evented embeddedable interface that implements observer

func (*Evented) Emit

func (s *Evented) Emit(e Event)

Emit queues an event for notification.

func (*Evented) Notify

func (s *Evented) Notify(ctx context.Context)

Notify flushes and sends notifications.

func (*Evented) Subscribe

func (s *Evented) Subscribe(o Observer)

Subscribe adds Observers to send events to

func (*Evented) Unsubscribe

func (s *Evented) Unsubscribe(o Observer)

Unsubscribe removes an observer from being notified

type Observer

type Observer interface {
	On(context.Context, Event)
}

Observer implementers will be notified when events occur

type ObserverFunc

type ObserverFunc func(context.Context, Event)

ObserverFunc function wrapper for Observer interface

func (ObserverFunc) On

func (o ObserverFunc) On(ctx context.Context, e Event)

On statifies Observer interface

type Subject

type Subject interface {
	Subscribe(o Observer)
	Unsubscribe(o Observer)
	Emit(e Event)
	Notify(context.Context)
}

Subject defines components that can be observered

Jump to

Keyboard shortcuts

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