state

package
v2.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: GPL-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalState = New(js.Null())

Functions

func Update added in v2.7.0

func Update(key Keyer, v interface{}) error

Update updates the stateful element in the state map.

func With added in v2.7.0

func With(value interface{}, e StatefulElement) error

With adds the stateful element to the state map.

func Without added in v2.7.0

func Without(e ...Keyer) error

Without removes the stateful element from the state map.

Types

type Editor added in v2.7.0

type Editor interface {
	EditState(value interface{}) error
}

type Key added in v2.7.0

type Key string

func (Key) Key added in v2.7.0

func (k Key) Key() string

type Keyer added in v2.7.0

type Keyer interface {
	Key() string
}

type State

type State struct {
	Root     js.Value
	Elements map[string][]StatefulElement
	Flags    StateFlags
	OnUpdate func()
}

func New added in v2.5.7

func New(root js.Value) *State

func (*State) Clear

func (s *State) Clear()

func (*State) Update added in v2.7.0

func (s *State) Update(key Keyer, v interface{}) error

func (*State) With added in v2.7.0

func (s *State) With(value interface{}, e StatefulElement) error

func (*State) Without added in v2.7.0

func (s *State) Without(e ...Keyer) error

type StateFlags added in v2.7.2

type StateFlags uint32
const (
	F_APPEND StateFlags = 1 << iota
	F_PREPEND
	F_NONE
)

type StatefulElement

type StatefulElement interface {
	Keyer
	Editor
	MarshalJS() js.Value
	Remove()
}

func Get

func Get(key Keyer) []StatefulElement

Get returns the stateful element from the state map.

func NewElement added in v2.7.0

func NewElement[T any](key string, v *js.Value, edit func(T, *js.Value) error) StatefulElement

Jump to

Keyboard shortcuts

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