goFE

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init()

func RenderChildren

func RenderChildren(component Component) string

func SetDocument

func SetDocument(doc *Document)

func UpdateComponentArray

func UpdateComponentArray[T Component, Props any](input *[]T, newLen int, newT func(props *Props) T, newProps []*Props)

UpdateComponentArray provides functionality to control a variable-length collection of components, such as a list of rows in a table, or any other collection of sub-components (children).

Types

type Component

type Component interface {
	Render() string
	GetID() uuid.UUID
	GetChildren() []Component
	InitEventListeners()
}

type Document

type Document struct {
	// contains filtered or unexported fields
}

func GetDocument

func GetDocument() *Document

func NewDocument

func NewDocument(componentTree []Component) *Document

func (*Document) AddEventListener

func (d *Document) AddEventListener(id uuid.UUID, event string, callback js.Func)

func (*Document) Append

func (d *Document) Append(component Component)

func (*Document) GetComponentTree

func (d *Document) GetComponentTree() []Component

func (*Document) Init

func (d *Document) Init()

type State

type State[T any] struct {
	Value *T
	// contains filtered or unexported fields
}

State is a generic struct that holds a value and a channel

func NewState

func NewState[T any](component Component, value *T) (*State[T], func(*T))

NewState creates a new instance of frontend state. It returns a pointer to the new state, with initial value, and a function to set the state.

func (*State[T]) AddEffect

func (s *State[T]) AddEffect(effect func(value *T))

AddEffect adds an effect to the state. An effect is a function that is called whenever the state changes.

Jump to

Keyboard shortcuts

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