react

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

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

func NewCommand

func NewCommand(execute func(), canExecute func() bool) *Command

func (*Command) CanExecute

func (c *Command) CanExecute() bool

func (*Command) Execute

func (c *Command) Execute()

func (*Command) OnCanExecuteChanged

func (c *Command) OnCanExecuteChanged(fn func(canExec bool)) func()

func (*Command) Refresh

func (c *Command) Refresh()

type ContextCommand

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

func NewContextCommand

func NewContextCommand(execute func(ctx context.Context), canExecute func(ctx context.Context) bool) *ContextCommand

func (*ContextCommand) CanExecute

func (c *ContextCommand) CanExecute(ctx context.Context) bool

func (*ContextCommand) Execute

func (c *ContextCommand) Execute(ctx context.Context)

func (*ContextCommand) OnCanExecuteChanged

func (c *ContextCommand) OnCanExecuteChanged(fn func(canExec bool)) func()

func (*ContextCommand) Refresh

func (c *ContextCommand) Refresh(ctx context.Context)

type EnumCommand

type EnumCommand[T comparable] struct {
	// contains filtered or unexported fields
}

func NewEnumCommand

func NewEnumCommand[T comparable]() *EnumCommand[T]

func (*EnumCommand[T]) Execute

func (c *EnumCommand[T]) Execute(val T)

func (*EnumCommand[T]) On

func (c *EnumCommand[T]) On(val T) *Command

func (*EnumCommand[T]) Register

func (c *EnumCommand[T]) Register(on T, cmd *Command) func()

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

func NewList

func NewList[T any]() *List[T]

func (*List[T]) Append

func (l *List[T]) Append(v T)

func (*List[T]) AppendAll

func (l *List[T]) AppendAll(vs []T)

func (*List[T]) At

func (l *List[T]) At(i int) T

func (*List[T]) Clear

func (l *List[T]) Clear()

func (*List[T]) Items

func (l *List[T]) Items() []T

func (*List[T]) Len

func (l *List[T]) Len() int

func (*List[T]) OnChange

func (l *List[T]) OnChange(fn func()) func()

func (*List[T]) Remove

func (l *List[T]) Remove(i int)

func (*List[T]) Set

func (l *List[T]) Set(i int, v T)

func (*List[T]) SetItems

func (l *List[T]) SetItems(items []T)

type Observable

type Observable[T any] interface {
	Get() T
	OnChange(func(T)) func()
}

Observable is the read-only contract shared by Prop, CmpProp, and Derived values.

type Prop

type Prop[T any] struct {
	// contains filtered or unexported fields
}

func Derive

func Derive[S any, T comparable](source Observable[S], fn func(S) T) (*Prop[T], func())

Derive creates a new Prop whose value is computed from a source Observable. The returned Prop updates whenever the source changes, deduplicating equal values. The second return value stops the derivation when called.

func NewProp

func NewProp[T comparable](initial T) *Prop[T]

NewProp creates a Prop for comparable types, using == for equality.

func NewPropEq

func NewPropEq[T any](initial T, eq func(T, T) bool) *Prop[T]

NewPropEq creates a Prop for any type with a custom equality function.

func (*Prop[T]) Get

func (p *Prop[T]) Get() T

func (*Prop[T]) OnChange

func (p *Prop[T]) OnChange(fn func(T)) func()

func (*Prop[T]) OnValue

func (p *Prop[T]) OnValue(wanted T, fn func()) func()

OnValue registers fn to be called whenever the value becomes equal to wanted.

func (*Prop[T]) Poll

func (p *Prop[T]) Poll(ctx context.Context, every time.Duration, pollFn func() T)

Poll starts a goroutine that calls pollFn on the given interval and sets the result. Stops when ctx is cancelled.

func (*Prop[T]) Set

func (p *Prop[T]) Set(v T)

type Signal

type Signal[T any] struct {
	// contains filtered or unexported fields
}

func NewSignal

func NewSignal[T any]() *Signal[T]

func (*Signal[T]) Emit

func (s *Signal[T]) Emit(v T)

func (*Signal[T]) Subscribe

func (s *Signal[T]) Subscribe(fn func(T)) func()

type VoidSignal

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

VoidSignal is a Signal that carries no value.

func NewVoidSignal

func NewVoidSignal() *VoidSignal

func (*VoidSignal) Emit

func (s *VoidSignal) Emit()

func (*VoidSignal) Subscribe

func (s *VoidSignal) Subscribe(fn func()) func()

Jump to

Keyboard shortcuts

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