Documentation
¶
Index ¶
- func MustRemember[T any](c state.SupportState, key string, calc func() T) T
- func Remember[T any](c state.SupportState, key string, calc func() T) (T, error)
- func RememberUnsafe[T any](c state.SupportState, key string, calc func() T) T
- type MutableValue
- type MutableValueInterface
- type MutableValueTyped
- type MutableValueTypedWrapper
- type PersistentState
- type PersistentStateInterface
- type TypedMutableValueInterface
- func MustState[T any](c state.SupportState, key string, initial func() T) TypedMutableValueInterface[T]
- func State[T any](c state.SupportState, key string, initial func() T) (TypedMutableValueInterface[T], error)
- func StateUnsafe[T any](c state.SupportState, key string, initial func() T) TypedMutableValueInterface[T]
- func WrapMutableValue[T any](mv *MutableValue) (TypedMutableValueInterface[T], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRemember ¶
func MustRemember[T any](c state.SupportState, key string, calc func() T) T
func RememberUnsafe ¶
func RememberUnsafe[T any](c state.SupportState, key string, calc func() T) T
Types ¶
type MutableValue ¶
type MutableValue struct {
// contains filtered or unexported fields
}
MutableValue is a trivial state container.
func NewMutableValue ¶
func (*MutableValue) Get ¶
func (mv *MutableValue) Get() any
func (*MutableValue) Set ¶
func (mv *MutableValue) Set(value any)
type MutableValueInterface ¶
type MutableValueInterface = state.MutableValue
type MutableValueTyped ¶
type MutableValueTyped[T any] struct { // contains filtered or unexported fields }
func NewMutableValueTyped ¶
func NewMutableValueTyped[T any](initial T, changeNotifier func(T), compare func(T, T) bool) *MutableValueTyped[T]
type MutableValueTypedWrapper ¶
type MutableValueTypedWrapper[T any] struct { // contains filtered or unexported fields }
func (*MutableValueTypedWrapper[T]) Get ¶
func (w *MutableValueTypedWrapper[T]) Get() T
func (*MutableValueTypedWrapper[T]) Set ¶
func (w *MutableValueTypedWrapper[T]) Set(value T)
func (*MutableValueTypedWrapper[T]) Unwrap ¶
func (w *MutableValueTypedWrapper[T]) Unwrap() MutableValueInterface
type PersistentState ¶
type PersistentState struct {
// contains filtered or unexported fields
}
func (*PersistentState) GetState ¶
func (ps *PersistentState) GetState(id string, initial func() any) MutableValueInterface
func (*PersistentState) SetOnStateChange ¶
func (ps *PersistentState) SetOnStateChange(callback func())
type PersistentStateInterface ¶
type PersistentStateInterface = state.PersistentState
func NewPersistentState ¶
func NewPersistentState(scopes map[string]MutableValueInterface) PersistentStateInterface
type TypedMutableValueInterface ¶
type TypedMutableValueInterface[T any] = state.TypedMutableValue[T]
func MustState ¶
func MustState[T any](c state.SupportState, key string, initial func() T) TypedMutableValueInterface[T]
func State ¶
func State[T any](c state.SupportState, key string, initial func() T) (TypedMutableValueInterface[T], error)
func StateUnsafe ¶
func StateUnsafe[T any](c state.SupportState, key string, initial func() T) TypedMutableValueInterface[T]
func WrapMutableValue ¶
func WrapMutableValue[T any](mv *MutableValue) (TypedMutableValueInterface[T], error)
Click to show internal directories.
Click to hide internal directories.