beam

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beam

type Beam[T any] interface {
	Watch(ctx context.Context, w Watcher[T]) (context.CancelFunc, bool)
	// contains filtered or unexported methods
}

type Cinema

type Cinema = *cinema

func NewCinema

func NewCinema(parent Cinema, door Door, runtime shredder.Runtime) Cinema

func (Cinema) IsEmpty

func (c Cinema) IsEmpty() bool

func (Cinema) ReadFrame added in v0.8.14

func (c Cinema) ReadFrame() shredder.Frame

type Core

type Core interface {
	Cinema() Cinema
}

type DerivedBeam added in v0.9.8

type DerivedBeam[T1 any, T2 any] struct {
	// contains filtered or unexported fields
}

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 (b *DerivedBeam[T1, T2]) ReadAndSub(ctx context.Context, onValue func(context.Context, T2) bool) (T2, bool)

func (*DerivedBeam[T1, T2]) Sub added in v0.9.8

func (b *DerivedBeam[T1, T2]) Sub(ctx context.Context, onValue func(context.Context, T2) bool) bool

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 Door

type Door interface {
	ReadFrame() shredder.Frame
	Context() context.Context
}

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 (s *SourceBeam[T]) ReadAndSub(ctx context.Context, onValue func(context.Context, T) bool) (T, bool)

func (*SourceBeam[T]) Sub added in v0.9.8

func (s *SourceBeam[T]) Sub(ctx context.Context, onValue func(context.Context, T) bool) bool

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)

func (*SourceBeam[T]) XMutate added in v0.9.8

func (s *SourceBeam[T]) XMutate(ctx context.Context, m func(T) T) <-chan error

XMutate behaves like [Source.Mutate] and returns a completion channel.

func (*SourceBeam[T]) XUpdate added in v0.9.8

func (s *SourceBeam[T]) XUpdate(ctx context.Context, v T) <-chan error

XUpdate behaves like [Source.Update] and returns a completion channel.

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.

Jump to

Keyboard shortcuts

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