app

package
v0.0.0-...-a8d3856 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterInitializedAnd

func FilterInitializedAnd(filters ...filterInitialized) filterInitialized

FilterInitializedAnd returns true if all filters returns true or no filters given.

func FilterRecordAddedAnd

func FilterRecordAddedAnd(filters ...filterRecordAdded) filterRecordAdded

FilterRecordAddedAnd returns true if all filters returns true or no filters given.

Types

type App

type App struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New() *App

func (*App) AddRecord

func (a *App) AddRecord(rec Record) error

func (*App) GetNewestRecord

func (a *App) GetNewestRecord() *Record

func (*App) Initialize

func (a *App) Initialize()

func (*App) SubscribeInitialized

func (t *App) SubscribeInitialized(c OnInitialized, ee EventEnver, filters ...filterInitialized)

SubscribeInitialized adds or replaces c subscription to the topic using given filters. Provided ee is locked before calling c.OnInitialized and unlocked (with render, if it'll return true) when it returns.

func (*App) SubscribeRecordAdded

func (t *App) SubscribeRecordAdded(c OnRecordAdded, ee EventEnver, filters ...filterRecordAdded)

SubscribeRecordAdded adds or replaces c subscription to the topic using given filters. Provided ee is locked before calling c.OnRecordAdded and unlocked (with render, if it'll return true) when it returns.

func (*App) UnsubscribeInitialized

func (t *App) UnsubscribeInitialized(c OnInitialized)

UnsubscribeInitialized unsubscribes c from the topic.

func (*App) UnsubscribeRecordAdded

func (t *App) UnsubscribeRecordAdded(c OnRecordAdded)

UnsubscribeRecordAdded unsubscribes c from the topic.

type Appl

type Appl interface {
	// GetNewestRecord returns newest or nil if there are no records.
	GetNewestRecord() *Record
	AddRecord(Record) error
	TopicInitialized
	TopicRecordAdded
}

type EventEnver

type EventEnver interface {
	EventEnv() vugu.EventEnv
}

type EventInitialized

type EventInitialized struct{}

type EventRecordAdded

type EventRecordAdded struct {
	Data Record
}

type OnInitialized

type OnInitialized interface {
	OnInitialized(EventInitialized) bool // Return true to request re-render.
}

OnInitialized must be implemented by EventInitialized subscribers. It'll be called with locked EventEnv.

type OnRecordAdded

type OnRecordAdded interface {
	OnRecordAdded(EventRecordAdded) bool // Return true to request re-render.
}

OnRecordAdded must be implemented by EventRecordAdded subscribers. It'll be called with locked EventEnv.

type Record

type Record struct {
	ID       int
	Start    time.Time
	Duration time.Duration // 15m…23h45m, step 15m.
	Activity string
	Actors   []string
	Customer string
	Details  string
}

type TopicInitialized

type TopicInitialized interface {
	SubscribeInitialized(c OnInitialized, ee EventEnver, filters ...filterInitialized)
	UnsubscribeInitialized(c OnInitialized)
}

TopicInitialized manages subscription on EventInitialized. While filtering can be implemented inside OnInitialized method, using filters may increase performance because filters will be called without locked EventEnv. Subscriber will get an event if there are no filters provided or ANY of given filters match.

type TopicRecordAdded

type TopicRecordAdded interface {
	SubscribeRecordAdded(c OnRecordAdded, ee EventEnver, filters ...filterRecordAdded)
	UnsubscribeRecordAdded(c OnRecordAdded)
}

TopicRecordAdded manages subscription on EventRecordAdded. While filtering can be implemented inside OnRecordAdded method, using filters may increase performance because filters will be called without locked EventEnv. Subscriber will get an event if there are no filters provided or ANY of given filters match.

Jump to

Keyboard shortcuts

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