Documentation ¶
Overview ¶
Package value provides atomic values with update notifications.
Index ¶
- type ErrorValue
- func (e *ErrorValue) Error(err error) bool
- func (e *ErrorValue) Get() (interface{}, error)
- func (e *ErrorValue) Next() <-chan struct{}
- func (e *ErrorValue) Set(value interface{})
- func (e *ErrorValue) SetOrError(val interface{}, err error) bool
- func (e *ErrorValue) Subscribe() (sub <-chan struct{}, done func())
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorValue ¶
type ErrorValue struct {
// contains filtered or unexported fields
}
ErrorValue adds an error to Value, allowing storage of either a value (interface{}) or an error.
func (*ErrorValue) Error ¶
func (e *ErrorValue) Error(err error) bool
Error replaces the stored value and returns true if non-nil, and simply returns false if nil.
func (*ErrorValue) Get ¶
func (e *ErrorValue) Get() (interface{}, error)
Get returns the currently stored value or error.
func (*ErrorValue) Next ¶
func (e *ErrorValue) Next() <-chan struct{}
Next returns a channel that will be closed on the next update, value or error.
func (*ErrorValue) Set ¶
func (e *ErrorValue) Set(value interface{})
Set updates the stored value and clears any error.
func (*ErrorValue) SetOrError ¶
func (e *ErrorValue) SetOrError(val interface{}, err error) bool
SetOrError combines Set and Error. It sets the error value and returns true if err is non-nil, otherwise it clears the error and sets the given value.
func (*ErrorValue) Subscribe ¶
func (e *ErrorValue) Subscribe() (sub <-chan struct{}, done func())
Subscribe returns a channel that will receive an empty struct{} on each value change (including errors), until it's cleaned up using the done func.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value provides atomic value storage with update notifications.
func (*Value) Next ¶
func (v *Value) Next() <-chan struct{}
Next returns a channel that will be closed on the next update. Useful in a select, or as <-Next() to wait for value changes.