Documentation
¶
Index ¶
- func MustRemember[T any](c SupportState, key string, calc func() T) T
- func NotifyRead(source any)
- func Remember[T any](c SupportState, key string, calc func() T) (T, error)
- func RememberUnsafe[T any](c SupportState, key string, calc func() T) T
- func WithReadObserver(observer ReadObserver, block func())
- type DerivedState
- type Memo
- type MemoTyped
- type MutableValue
- type PersistentState
- type ReadObserver
- type SupportState
- type TypedMutableValue
- type TypedValue
- type Value
- type Versionable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRemember ¶
func MustRemember[T any](c SupportState, key string, calc func() T) T
func NotifyRead ¶ added in v0.1.61
func NotifyRead(source any)
NotifyRead notifies the active read observer that a state object has been read. Source is typically the state object itself (e.g. *MutableValue).
func RememberUnsafe ¶
func RememberUnsafe[T any](c SupportState, key string, calc func() T) T
func WithReadObserver ¶ added in v0.1.61
func WithReadObserver(observer ReadObserver, block func())
WithReadObserver executes the block with the given read observer. It restores the previous observer after the block finishes.
Types ¶
type DerivedState ¶ added in v0.1.61
type DerivedState[T any] struct { // contains filtered or unexported fields }
func DerivedStateOf ¶ added in v0.1.61
func DerivedStateOf[T any](calculation func() T) *DerivedState[T]
func DerivedStateOfCustom ¶ added in v0.1.61
func DerivedStateOfCustom[T any](calculation func() T, compare func(T, T) bool) *DerivedState[T]
DerivedStateOfCustom allows providing a custom comparison function
func (*DerivedState[T]) Get ¶ added in v0.1.61
func (ds *DerivedState[T]) Get() any
func (*DerivedState[T]) Version ¶ added in v0.1.61
func (ds *DerivedState[T]) Version() int64
type Memo ¶
type Memo = immap.ImmutableMap[any]
type MemoTyped ¶
type MemoTyped[T any] = immap.ImmutableMap[T]
type MutableValue ¶
type PersistentState ¶
type PersistentState interface {
GetState(key string, initial func() any) MutableValue
SetOnStateChange(callback func())
}
type ReadObserver ¶ added in v0.1.61
type ReadObserver func(source any)
type SupportState ¶
type TypedMutableValue ¶
type TypedMutableValue[T any] interface { TypedValue[T] Set(value T) Unwrap() MutableValue }
type TypedValue ¶
type TypedValue[T any] interface { Get() T }
type Versionable ¶ added in v0.1.61
type Versionable interface {
Version() int64
}
Click to show internal directories.
Click to hide internal directories.