state

package
v0.1.53 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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 Remember

func Remember[T any](c SupportState, key string, calc func() T) (T, error)

func RememberUnsafe

func RememberUnsafe[T any](c SupportState, key string, calc func() T) T

Types

type Memo

type Memo = immap.ImmutableMap[any]

type MemoTyped

type MemoTyped[T any] = immap.ImmutableMap[T]

func EmptyMemo

func EmptyMemo[T any]() MemoTyped[T]

type MutableValue

type MutableValue interface {
	Value
	Set(value any)
}

type PersistentState

type PersistentState interface {
	GetState(key string, initial func() any) MutableValue
	SetOnStateChange(callback func())
}

type SupportState

type SupportState interface {
	Remember(key string, calc func() any) any          // transient state
	State(key string, initial func() any) MutableValue // persistent state
}

type TypedMutableValue

type TypedMutableValue[T any] interface {
	TypedValue[T]
	Set(value T)

	Unwrap() MutableValue
}

type TypedValue

type TypedValue[T any] interface {
	Get() T
}

type Value

type Value interface {
	Get() any
}

Jump to

Keyboard shortcuts

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