Documentation ¶
Index ¶
- Constants
- func P(propName string, propVal any) map[string]any
- func UseEffect(ctx context.Context, fn func() func(), deps []any)
- func UseId(ctx context.Context) string
- func UseState[T any](ctx context.Context, initialVal T) (T, func(T))
- type CFunc
- type ChildKey
- type Component
- type EffectWorkElem
- type Elem
- type Hook
- type RootElem
- func (r *RootElem) AddEffectWork(id string, effectIndex int)
- func (r *RootElem) AddRenderWork(id string)
- func (r *RootElem) Event(id string, propName string)
- func (r *RootElem) MakeVDom() *Elem
- func (r *RootElem) RegisterComponent(name string, cfunc CFunc)
- func (r *RootElem) Render(elem *Elem)
- func (r *RootElem) SetOuterCtx(ctx context.Context)
- type VDomContextVal
- type VDomFuncType
- type VDomRefType
Constants ¶
View Source
const ( WorkType_Render = "render" WorkType_Effect = "effect" )
View Source
const ChildrenPropKey = "children"
View Source
const FragmentTag = "#fragment"
View Source
const KeyPropKey = "key"
View Source
const TextTag = "#text"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EffectWorkElem ¶
type Elem ¶
type Elem struct { Id string `json:"id,omitempty"` // used for vdom Tag string `json:"tag"` Props map[string]any `json:"props,omitempty"` Children []Elem `json:"children,omitempty"` Text string `json:"text,omitempty"` }
doubles as VDOM structure
type Hook ¶
type Hook struct { Init bool // is initialized Idx int // index in the hook array Fn func() func() // for useEffect UnmountFn func() // for useEffect Val any // for useState, useMemo, useRef Deps []any }
generic hook structure
type RootElem ¶
type RootElem struct { OuterCtx context.Context Root *Component CFuncs map[string]CFunc CompMap map[string]*Component // component id -> component EffectWorkQueue []*EffectWorkElem NeedsRenderMap map[string]bool }
func (*RootElem) AddEffectWork ¶
func (*RootElem) AddRenderWork ¶
func (*RootElem) RegisterComponent ¶
func (*RootElem) SetOuterCtx ¶
type VDomContextVal ¶
type VDomFuncType ¶
type VDomFuncType struct { Fn any `json:"-"` // the actual function to call (called via reflection) FuncType string `json:"#func"` StopPropagation bool `json:"#stopPropagation,omitempty"` PreventDefault bool `json:"#preventDefault,omitempty"` Keys []string `json:"#keys,omitempty"` // special for keyDown events a list of keys to "capture" }
can be used to set preventDefault/stopPropagation
type VDomRefType ¶
Click to show internal directories.
Click to hide internal directories.