liveview

package
v0.0.0-...-d055956 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MuLayout sync.Mutex         = sync.Mutex{}
	Layaouts map[string]*Layout = make(map[string]*Layout)
)
View Source
var (
	FuncMapTemplate = template.FuncMap{
		"mount": func(id string) string {
			return "<span id='mount_span_" + id + "'></span>"
		},
		"eqInt": func(value1, value2 int) bool { return value1 == value2 },
	}
)

Functions

func ContainsString

func ContainsString(s []string, e string) bool

func Exists

func Exists(name string) bool

func FileToString

func FileToString(name string) (string, error)

func HandleReover

func HandleReover()

func HandleReoverMsg

func HandleReoverMsg(msg string)

func HandleReoverPass

func HandleReoverPass()

func Join

func Join(ids ...string)

func New

func New[T Component](id string, c T) T

func SendToAllLayouts

func SendToAllLayouts(msg interface{})

func SendToLayouts

func SendToLayouts(msg interface{}, uuids ...string)

func StringToFile

func StringToFile(filenanme string, content string) error

Types

type BiMap

type BiMap[T1 comparable, T2 comparable] struct {
	// contains filtered or unexported fields
}

func NewBiMap

func NewBiMap[T1 comparable, T2 comparable]() *BiMap[T1, T2]

func (*BiMap[T1, T2]) Delete

func (b *BiMap[T1, T2]) Delete(key T1)

func (*BiMap[T1, T2]) DeleteByValue

func (b *BiMap[T1, T2]) DeleteByValue(value T2)

func (*BiMap[T1, T2]) Get

func (b *BiMap[T1, T2]) Get(key T1) (T2, bool)

func (*BiMap[T1, T2]) GetAll

func (b *BiMap[T1, T2]) GetAll() map[T1]T2

func (*BiMap[T1, T2]) GetAllValues

func (b *BiMap[T1, T2]) GetAllValues() map[T2]T1

func (*BiMap[T1, T2]) GetByValue

func (b *BiMap[T1, T2]) GetByValue(value T2) (T1, bool)

func (*BiMap[T1, T2]) Set

func (b *BiMap[T1, T2]) Set(key T1, value T2)

type Component

type Component interface {
	// GetTemplate return html template for render with component in the {{.}}
	GetTemplate() string
	// Start it will invoke in the mount time
	Start()
	GetDriver() LiveDriver
}

Component it is interface for implement one component

type ComponentDriver

type ComponentDriver[T Component] struct {
	Component T

	IdComponent string

	DriversPage *map[string]LiveDriver

	// Events has rewrite of our implementings of  events, examples click, change, keyup, keydown, etc
	Events map[string]func(c T, data interface{})
	Data   interface{}
	// contains filtered or unexported fields
}

ComponentDriver this is the driver for component, with this struct we can execute our methods in the web

func NewDriver

func NewDriver[T Component](id string, c T) *ComponentDriver[T]

Create Driver with component

func NewLayout

func NewLayout(uid string, paramHtml string) *ComponentDriver[*Layout]

func (*ComponentDriver[T]) AddNode

func (cw *ComponentDriver[T]) AddNode(id string, value string)

AddNode add node to id

func (*ComponentDriver[T]) Commit

func (cw *ComponentDriver[T]) Commit()

Commit render of component

func (*ComponentDriver[T]) EvalScript

func (cw *ComponentDriver[T]) EvalScript(code string)

EvalScript execute eval($code);

func (*ComponentDriver[T]) ExecuteEvent

func (cw *ComponentDriver[T]) ExecuteEvent(name string, data interface{})

ExecuteEvent execute events

func (*ComponentDriver[T]) FillValue

func (cw *ComponentDriver[T]) FillValue(value string)

FillValue is same SetHTML

func (*ComponentDriver[T]) FillValueById

func (cw *ComponentDriver[T]) FillValueById(id string, value string)

FillValue is same SetHTML

func (*ComponentDriver[T]) GetComponet

func (cw *ComponentDriver[T]) GetComponet() Component

GetID return id of driver

func (*ComponentDriver[T]) GetData

func (cw *ComponentDriver[T]) GetData() interface{}

func (*ComponentDriver[T]) GetDriverById

func (cw *ComponentDriver[T]) GetDriverById(id string) LiveDriver

GetID return id of driver

func (*ComponentDriver[T]) GetElementById

func (cw *ComponentDriver[T]) GetElementById(id string) string

GetElementById same as GetValue

func (*ComponentDriver[T]) GetHTML

func (cw *ComponentDriver[T]) GetHTML() string

GetHTML return document.getElementById("$id").innerHTML

func (*ComponentDriver[T]) GetID

func (cw *ComponentDriver[T]) GetID() string

GetID return id of driver

func (*ComponentDriver[T]) GetIDComponet

func (cw *ComponentDriver[T]) GetIDComponet() string

func (*ComponentDriver[T]) GetPropertie

func (cw *ComponentDriver[T]) GetPropertie(name string) string

GetPropertie return document.getElementById("$id")[$propertie]

func (*ComponentDriver[T]) GetStyle

func (cw *ComponentDriver[T]) GetStyle(propertie string) string

GetStyle return document.getElementById("$id").style["$propertie"]

func (*ComponentDriver[T]) GetText

func (cw *ComponentDriver[T]) GetText() string

GetText return document.getElementById("$id").innerText

func (*ComponentDriver[T]) GetValue

func (cw *ComponentDriver[T]) GetValue() string

GetValue return document.getElementById("$id").value

func (*ComponentDriver[T]) Mount

func (cw *ComponentDriver[T]) Mount(component Component) LiveDriver

Mount mount component in other component

func (*ComponentDriver[T]) MountWithStart

func (cw *ComponentDriver[T]) MountWithStart(id string, componentDriver LiveDriver) LiveDriver

Mount mount component in other component"mount_span_" +

func (*ComponentDriver[T]) Remove

func (cw *ComponentDriver[T]) Remove(id string)

Remove

func (*ComponentDriver[T]) SetData

func (cw *ComponentDriver[T]) SetData(data interface{})

func (*ComponentDriver[T]) SetEvent

func (cw *ComponentDriver[T]) SetEvent(name string, fx func(c T, data interface{}))

func (*ComponentDriver[T]) SetHTML

func (cw *ComponentDriver[T]) SetHTML(value string)

SetHTML is same FillValue :p haha, execute document.getElementById("$id").innerHTML = $value

func (*ComponentDriver[T]) SetID

func (cw *ComponentDriver[T]) SetID(id string)

SetID set id of driver

func (*ComponentDriver[T]) SetPropertie

func (cw *ComponentDriver[T]) SetPropertie(propertie string, value interface{})

SetPropertie execute document.getElementById("$id")[$propertie] = $value

func (*ComponentDriver[T]) SetStyle

func (cw *ComponentDriver[T]) SetStyle(style string)

SetStyle execute document.getElementById("$id").style.cssText = $style

func (*ComponentDriver[T]) SetText

func (cw *ComponentDriver[T]) SetText(value string)

SetText execute document.getElementById("$id").innerText = $value

func (*ComponentDriver[T]) SetValue

func (cw *ComponentDriver[T]) SetValue(value interface{})

SetValue execute document.getElementById("$id").value = $value|

func (*ComponentDriver[T]) StartDriver

func (cw *ComponentDriver[T]) StartDriver(drivers *map[string]LiveDriver, channelIn *map[string]chan interface{}, channel chan (map[string]interface{}))

type Layout

type Layout struct {
	*ComponentDriver[*Layout]
	UUID                string
	Html                string
	ChanIn              chan interface{}
	HandlerEventIn      *func(data interface{})
	HandlerEventTime    *func()
	HandlerEventDestroy *func(id string)
	HandlerFirstTime    *func()
	IntervalEventTime   time.Duration
}

func (*Layout) GetDriver

func (t *Layout) GetDriver() LiveDriver

func (*Layout) GetTemplate

func (t *Layout) GetTemplate() string

func (*Layout) SetHandlerEventDestroy

func (t *Layout) SetHandlerEventDestroy(fx func(id string))

func (*Layout) SetHandlerEventIn

func (t *Layout) SetHandlerEventIn(fx func(data interface{}))

func (*Layout) SetHandlerEventTime

func (t *Layout) SetHandlerEventTime(IntervalEventTime time.Duration, fx func())

func (*Layout) SetHandlerFirstTime

func (t *Layout) SetHandlerFirstTime(fx func())

func (*Layout) Start

func (t *Layout) Start()

type LiveDriver

type LiveDriver interface {
	GetID() string
	SetID(string)
	StartDriver(*map[string]LiveDriver, *map[string]chan interface{}, chan (map[string]interface{}))
	GetIDComponet() string
	ExecuteEvent(name string, data interface{})

	GetComponet() Component
	Mount(component Component) LiveDriver
	MountWithStart(id string, componentDriver LiveDriver) LiveDriver

	Commit()
	Remove(string)
	AddNode(string, string)
	FillValue(string)
	SetHTML(string)
	SetText(string)
	SetPropertie(string, interface{})
	SetValue(interface{})
	EvalScript(string)
	SetStyle(string)

	FillValueById(id string, value string)

	GetPropertie(string) string
	GetDriverById(id string) LiveDriver
	GetText() string
	GetHTML() string
	GetStyle(string) string
	GetValue() string
	GetElementById(string) string

	SetData(interface{})
}

type None

type None struct {
	*ComponentDriver[*None]
	Template string
}

func NewWithTemplate

func NewWithTemplate(id string, template string) *None

func (*None) GetDriver

func (t *None) GetDriver() LiveDriver

func (*None) GetTemplate

func (t *None) GetTemplate() string

func (*None) Start

func (t *None) Start()

type PageControl

type PageControl struct {
	Path      string
	Title     string
	HeadCode  string
	Lang      string
	Css       string
	LiveJs    string
	AfterCode string
	Router    *echo.Echo
	Debug     bool
}

func (*PageControl) Register

func (pc *PageControl) Register(fx func() LiveDriver)

Register this method to register in router of Echo page and websocket

Jump to

Keyboard shortcuts

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