Documentation
¶
Index ¶
- Variables
- func CallBeforeCreated(i interface{}) error
- func CallBeforeDestroy(i interface{}) error
- func CallBeforeUpdate(p *Element) error
- func CallMounted(i interface{}) error
- func CallUpdated(p *Element) error
- func Changed(newEl, oldEl interface{}) (bool, bool, error)
- func IsComponent(c interface{}) bool
- func IsElement(c interface{}) bool
- func IsString(c interface{}) bool
- func RemoveStrings(arr []interface{}) []interface{}
- func ToGetComponentList(childes ...interface{}) []interface{}
- func UnSpliceBody(body []interface{}) []interface{}
- type BackEnd
- type Bind
- type C
- type Component
- func (c *Component) ConsoleError(a ...interface{})
- func (c *Component) ConsoleLog(a ...interface{})
- func (c *Component) RenderElement() *Element
- func (component *Component) Update()
- func (component *Component) UpdateWithError() error
- func (c *Component) WarnError(err error)
- func (c *Component) WarnIfNot(ok bool)
- type DynamicComponent
- type DynamicElement
- type E
- type Effect
- type Element
- type EmptyRoot
- type Event
- type External
- type F
- type FunctionalComponent
- func (f *FunctionalComponent) Init(notPointer bool, renderer func() *E) *C
- func (root *FunctionalComponent) Render() *Element
- func (root *FunctionalComponent) UseEffect(effect Effect)
- func (root *FunctionalComponent) UseState(defaultVal interface{}) (func() interface{}, func(interface{}))
- func (root *FunctionalComponent) UseStateBool(defaultVal bool) (func() bool, func(bool))
- func (root *FunctionalComponent) UseStateFloat32(defaultVal float32) (func() float32, func(float32))
- func (root *FunctionalComponent) UseStateFloat64(defaultVal float64) (func() float64, func(float64))
- func (root *FunctionalComponent) UseStateInt(defaultVal int) (func() int, func(int))
- func (root *FunctionalComponent) UseStateInt8(defaultVal int8) (func() int8, func(int8))
- func (root *FunctionalComponent) UseStateInt16(defaultVal int16) (func() int16, func(int16))
- func (root *FunctionalComponent) UseStateInt32(defaultVal int32) (func() int32, func(int32))
- func (root *FunctionalComponent) UseStateInt64(defaultVal int64) (func() int64, func(int64))
- func (root *FunctionalComponent) UseStateString(defaultVal string) (func() string, func(string))
- func (root *FunctionalComponent) UseStateUint(defaultVal uint) (func() uint, func(uint))
- func (root *FunctionalComponent) UseStateUint8(defaultVal uint8) (func() uint8, func(uint8))
- func (root *FunctionalComponent) UseStateUint16(defaultVal uint16) (func() uint16, func(uint16))
- func (root *FunctionalComponent) UseStateUint32(defaultVal uint32) (func() uint32, func(uint32))
- func (root *FunctionalComponent) UseStateUint64(defaultVal uint64) (func() uint64, func(uint64))
- type G
- type Gas
- type HTMLDirective
- type Handler
- type Hook
- type HookWithControl
- type Hooks
- type Map
- type Object
- type RenderCore
- type RenderTask
- type RenderType
- type Template
Constants ¶
This section is empty.
Variables ¶
var CL = ToGetComponentList
CL alias for ToGetComponentList
var NE = NewElement
NE alias for NewElement
Functions ¶
func CallBeforeCreated ¶
func CallBeforeCreated(i interface{}) error
CallBeforeCreated call component and it's childes BeforeCreated hook
func CallBeforeDestroy ¶
func CallBeforeDestroy(i interface{}) error
CallBeforeDestroy call component and it's childes WillDestroy hook
func CallBeforeUpdate ¶
CallBeforeUpdate call BeforeUpdate hook
func CallMounted ¶
func CallMounted(i interface{}) error
CallMounted call component and it's childes Mounted hook
func IsComponent ¶
func IsComponent(c interface{}) bool
IsComponent return true if interface.(type) == *Component
func IsElement ¶
func IsElement(c interface{}) bool
IsElement return true if interface.(type) == *Element
func RemoveStrings ¶
func RemoveStrings(arr []interface{}) []interface{}
RemoveStrings remove all strings from []interface{}
func ToGetComponentList ¶
func ToGetComponentList(childes ...interface{}) []interface{}
ToGetComponentList return array by many parameters, because it's pretty
func UnSpliceBody ¶
func UnSpliceBody(body []interface{}) []interface{}
UnSpliceBody extract values fromm array to component childes
Types ¶
type BackEnd ¶
type BackEnd interface {
ExecTasks([]*RenderTask)
GetElement(*Element) interface{}
ChildNodes(interface{}) []interface{}
ConsoleLog(...interface{})
ConsoleError(...interface{})
}
BackEnd interface for calling platform-specific code
type Component ¶
type Component struct {
Root interface {
Render() *Element
}
Element *Element // last-time render by root element from
Hooks Hooks
RefsAllowed bool
Refs map[string]*Element
NotPointer bool // by default component is pointer
RC *RenderCore
}
Component logic node
func ElementToComponent ¶
ElementToComponent create static component from element
func (*Component) ConsoleError ¶
func (c *Component) ConsoleError(a ...interface{})
ConsoleError call BackEnd.ConsoleError
func (*Component) ConsoleLog ¶
func (c *Component) ConsoleLog(a ...interface{})
ConsoleLog call BackEnd.ConsoleLog
func (*Component) RenderElement ¶
RenderElement create element for elements tree
func (*Component) Update ¶
func (component *Component) Update()
Update update component childes with error warning
func (*Component) UpdateWithError ¶
UpdateWithError update component childes
type DynamicComponent ¶
type DynamicElement ¶
type Element ¶
type Element struct {
UUID string
IsPointer bool // by default element isn't pointer
Tag string
Attrs func() Map
RAttrs Map // last rendered Attrs
Handlers map[string]Handler // events handlers: onClick, onHover
HTML func() string
RHTML string
Childes, OldChildes []interface{}
Parent *Element // if element is root, parent is nil
RefName string
Component *Component // can be nil
RC *RenderCore
}
Element stucture for basic strucutre nodes (html elements, etc)
func NewElement ¶
NewElement create new element
func (*Element) BEElement ¶
func (e *Element) BEElement() interface{}
BEElement return element in backend implementation
func (*Element) GetElementUnsafely ¶
func (e *Element) GetElementUnsafely() interface{}
GetElementUnsafely return *dom.Element by component without warning
func (*Element) ParentComponent ¶
ParentComponent return first component in element parents tree
func (*Element) UpdateChildes ¶
func (e *Element) UpdateChildes()
UpdateChildes update element childes
type External ¶
type External struct {
Body []interface{}
Slots map[string]interface{}
Templates map[string]Template
Attrs func() Map
}
External structure for passing values to external components
type FunctionalComponent ¶
type FunctionalComponent struct {
C *Component
// contains filtered or unexported fields
}
FunctionalComponent wrapper for Component with react hooks (in gas maner)
func (*FunctionalComponent) Init ¶
func (f *FunctionalComponent) Init(notPointer bool, renderer func() *E) *C
Init create *C from *F
func (*FunctionalComponent) Render ¶
func (root *FunctionalComponent) Render() *Element
Render return functionalComponent childes
func (*FunctionalComponent) UseEffect ¶
func (root *FunctionalComponent) UseEffect(effect Effect)
UseEffect add effect
func (*FunctionalComponent) UseState ¶
func (root *FunctionalComponent) UseState(defaultVal interface{}) (func() interface{}, func(interface{}))
UseState create new state value
func (*FunctionalComponent) UseStateBool ¶
func (root *FunctionalComponent) UseStateBool(defaultVal bool) (func() bool, func(bool))
func (*FunctionalComponent) UseStateFloat32 ¶
func (root *FunctionalComponent) UseStateFloat32(defaultVal float32) (func() float32, func(float32))
func (*FunctionalComponent) UseStateFloat64 ¶
func (root *FunctionalComponent) UseStateFloat64(defaultVal float64) (func() float64, func(float64))
func (*FunctionalComponent) UseStateInt ¶
func (root *FunctionalComponent) UseStateInt(defaultVal int) (func() int, func(int))
func (*FunctionalComponent) UseStateInt8 ¶
func (root *FunctionalComponent) UseStateInt8(defaultVal int8) (func() int8, func(int8))
func (*FunctionalComponent) UseStateInt16 ¶
func (root *FunctionalComponent) UseStateInt16(defaultVal int16) (func() int16, func(int16))
func (*FunctionalComponent) UseStateInt32 ¶
func (root *FunctionalComponent) UseStateInt32(defaultVal int32) (func() int32, func(int32))
func (*FunctionalComponent) UseStateInt64 ¶
func (root *FunctionalComponent) UseStateInt64(defaultVal int64) (func() int64, func(int64))
func (*FunctionalComponent) UseStateString ¶
func (root *FunctionalComponent) UseStateString(defaultVal string) (func() string, func(string))
func (*FunctionalComponent) UseStateUint ¶
func (root *FunctionalComponent) UseStateUint(defaultVal uint) (func() uint, func(uint))
func (*FunctionalComponent) UseStateUint8 ¶
func (root *FunctionalComponent) UseStateUint8(defaultVal uint8) (func() uint8, func(uint8))
func (*FunctionalComponent) UseStateUint16 ¶
func (root *FunctionalComponent) UseStateUint16(defaultVal uint16) (func() uint16, func(uint16))
func (*FunctionalComponent) UseStateUint32 ¶
func (root *FunctionalComponent) UseStateUint32(defaultVal uint32) (func() uint32, func(uint32))
func (*FunctionalComponent) UseStateUint64 ¶
func (root *FunctionalComponent) UseStateUint64(defaultVal uint64) (func() uint64, func(uint64))
type HTMLDirective ¶
type HTMLDirective struct {
Render func() string
Rendered string // here storing rendered html for Update functions
}
HTMLDirective struct for HTML Directive - storing render function and pre rendered render
type HookWithControl ¶
HookWithControl - lifecycle hook. Return true for rerender component childes
type Hooks ¶
type Hooks struct {
BeforeCreated HookWithControl // When parent already rendered (appended to DOM), but component Element don't yet (you can rerender childes)
Created Hook // When component has been created in golang only (Element isn't available)
Mounted Hook // When component has been mounted (Element is available)
BeforeDestroy Hook // Before component destroy (Element is available)
BeforeUpdate Hook // When component child don't updated
Updated Hook // After component child was updated
}
Hooks component lifecycle hooks
type Object ¶
type Object interface {
String() string
Int() int
Float() float64
Get(string) Object
Set(string, interface{})
GetString(string) string
GetBool(string) bool
GetInt(string) int
Call(string, ...interface{}) Object
Raw() interface{}
}
Object wrapper for js.Value
type RenderCore ¶
type RenderCore struct {
BE BackEnd
// contains filtered or unexported fields
}
RenderCore render station
func GetEmptyRenderCore ¶
func GetEmptyRenderCore() *RenderCore
GetEmptyRenderCore return epmty render core
func (*RenderCore) Add ¶
func (rc *RenderCore) Add(task *RenderTask)
Add push render tasks to render queue and trying to execute all queue
func (*RenderCore) GetAll ¶
func (rc *RenderCore) GetAll() []*RenderTask
GetAll return render nodes from queue
func (*RenderCore) UpdateElementChildes ¶
func (rc *RenderCore) UpdateElementChildes(_el interface{}, el *Element, new, old []interface{}, inReplaced bool) error
UpdateElementChildes compare new and old trees
type RenderTask ¶
type RenderTask struct {
ID int64
Type RenderType
Parent *Element
New, Old interface{} // *Element, string, int, ...
NodeParent, NodeNew, NodeOld interface{} // *dom.Element
ReplaceCanGoDeeper bool
InReplaced bool
}
RenderTask node storing changes
type RenderType ¶
type RenderType int
RenderType RenderTask type
const ( // RReplace type for replace node RReplace RenderType = iota // RReplaceHooks type for run after replace hooks RReplaceHooks // RCreate type for create nodes RCreate // RFirstRender type for first gas render RFirstRender // RDelete type for delete node RDelete // RRecreate type for recreate node RRecreate )
