Documentation
¶
Index ¶
- type Beam
- type Cinema
- type Core
- type DerivedBeam
- func (b *DerivedBeam[T1, T2]) Read(ctx context.Context) (T2, bool)
- func (b *DerivedBeam[T1, T2]) ReadAndSub(ctx context.Context, onValue func(context.Context, T2) bool) (T2, bool)
- func (b *DerivedBeam[T1, T2]) Sub(ctx context.Context, onValue func(context.Context, T2) bool) bool
- func (b *DerivedBeam[T1, T2]) Watch(ctx context.Context, w Watcher[T2]) (context.CancelFunc, bool)
- type Door
- type SourceBeam
- func (s *SourceBeam[T]) DisableSkipping()
- func (s *SourceBeam[T]) Get() T
- func (s *SourceBeam[T]) Mutate(ctx context.Context, m func(T) T)
- func (s *SourceBeam[T]) Read(ctx context.Context) (T, bool)
- func (s *SourceBeam[T]) ReadAndSub(ctx context.Context, onValue func(context.Context, T) bool) (T, bool)
- func (s *SourceBeam[T]) Sub(ctx context.Context, onValue func(context.Context, T) bool) bool
- func (s *SourceBeam[T]) Update(ctx context.Context, v T)
- func (s *SourceBeam[T]) Watch(ctx context.Context, w Watcher[T]) (context.CancelFunc, bool)
- func (s *SourceBeam[T]) XMutate(ctx context.Context, m func(T) T) <-chan error
- func (s *SourceBeam[T]) XUpdate(ctx context.Context, v T) <-chan error
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DerivedBeam ¶ added in v0.9.8
func NewBeam ¶
func NewBeam[T1 any, T2 comparable](source Beam[T1], cast func(T1) T2) *DerivedBeam[T1, T2]
func NewBeamEqual ¶
func NewBeamEqual[T1 any, T2 any](source Beam[T1], cast func(T1) T2, equal func(new T2, old T2) bool) *DerivedBeam[T1, T2]
func (*DerivedBeam[T1, T2]) Read ¶ added in v0.9.8
func (b *DerivedBeam[T1, T2]) Read(ctx context.Context) (T2, bool)
func (*DerivedBeam[T1, T2]) ReadAndSub ¶ added in v0.9.8
func (*DerivedBeam[T1, T2]) Watch ¶ added in v0.9.8
func (b *DerivedBeam[T1, T2]) Watch(ctx context.Context, w Watcher[T2]) (context.CancelFunc, bool)
type SourceBeam ¶ added in v0.9.8
type SourceBeam[T any] struct { // contains filtered or unexported fields }
func NewSource ¶
func NewSource[T comparable](init T) *SourceBeam[T]
NewSource creates a SourceBeam that uses `==` to suppress equal updates.
func NewSourceEqual ¶
func NewSourceEqual[T any](init T, equal func(new T, old T) bool) *SourceBeam[T]
NewSourceEqual creates a SourceBeam with a custom equality function.
func (*SourceBeam[T]) DisableSkipping ¶ added in v0.9.8
func (s *SourceBeam[T]) DisableSkipping()
DisableSkipping forces every committed value to propagate.
func (*SourceBeam[T]) Get ¶ added in v0.9.8
func (s *SourceBeam[T]) Get() T
Get returns the latest committed value.
func (*SourceBeam[T]) Mutate ¶ added in v0.9.8
func (s *SourceBeam[T]) Mutate(ctx context.Context, m func(T) T)
Mutate updates the value by applying m to the current value.
func (*SourceBeam[T]) Read ¶ added in v0.9.8
func (s *SourceBeam[T]) Read(ctx context.Context) (T, bool)
func (*SourceBeam[T]) ReadAndSub ¶ added in v0.9.8
func (*SourceBeam[T]) Update ¶ added in v0.9.8
func (s *SourceBeam[T]) Update(ctx context.Context, v T)
Update stores v and starts propagation.
func (*SourceBeam[T]) Watch ¶ added in v0.9.8
func (s *SourceBeam[T]) Watch(ctx context.Context, w Watcher[T]) (context.CancelFunc, bool)
type Watcher ¶
type Watcher[T any] interface { // Cancel is called when the watcher stops because of context cancellation or // an explicit cancel call. Cancel() // Watch receives the initial value synchronously and later updates // asynchronously. Returning true stops the watcher. Watch(ctx context.Context, value T) bool }
Watcher receives low-level lifecycle callbacks for a Beam.
Click to show internal directories.
Click to hide internal directories.