state

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultState

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

func NewDefaultState

func NewDefaultState() *DefaultState

func (*DefaultState) Get

func (s *DefaultState) Get(key string) (lang.Object, bool)

func (*DefaultState) Set

func (s *DefaultState) Set(key string, value lang.Object) bool

type Provider

type Provider struct {
	States map[string]State
	// contains filtered or unexported fields
}

Provider represents a state provider.

func Default

func Default() *Provider

func NewProvider

func NewProvider(stateMaker func() State) *Provider

NewProvider creates a new state provider.

func (*Provider) State

func (p *Provider) State(name string) State

State returns a state with the given name.

type State

type State interface {
	// Get retrieves the value associated with the given key.
	Get(key string) (lang.Object, bool)
	// Set sets the value associated with the given key.
	Set(key string, value lang.Object) bool
}

State represents a stateful object that can be used to store and retrieve data that is global and can be accessed by multiple threads.

Jump to

Keyboard shortcuts

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