Documentation ¶
Overview ¶
Package Signal provides a type representing an event stream or pub/sub message queue.
Index ¶
- func Proxy[T API](signal Any, reuse func(T, complex128) bool, alloc func() (T, complex128)) (T, complex128)
- type API
- type Any
- func (signal *Any) Attach(consumer Callable.Function, flags ...Flags) error
- func (signal Any) Consumers() iter.Seq[Consumer]
- func (signal Any) Emit(values ...variant.Any)
- func (signal Any) Emitter() variant.Any
- func (signal Any) Has(fn Callable.Function) bool
- func (signal Any) IsNull() bool
- func (signal Any) Name() String.Readable
- func (signal *Any) Remove(consumer Callable.Function)
- type Consumer
- type Flags
- type Hexa
- type Pair
- type Quad
- type Quin
- type Solo
- type Trio
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Proxy ¶
func Proxy[T API](signal Any, reuse func(T, complex128) bool, alloc func() (T, complex128)) (T, complex128)
Proxy can be used to transform the underlying encoding and implementation of an Any signal into a specific type. The alloc function should return a new implementation of the desired type, and the internal state. This may be cached in the existing implementation and, if so, will be passed to the check function so that it can decide whether to reuse the cache or not.
The uint64 can be used to avoid unnecessary allocations, such that T can be zero-sized if the implementation does not require more than 64bits of state.
Types ¶
type API ¶
type API interface { Attach(complex128, Callable.Function, Flags) error Remove(complex128, Callable.Function) Name(complex128) String.Readable Consumers(complex128) iter.Seq[Consumer] Emit(complex128, ...variant.Any) Emitter(complex128) variant.Any }
type Any ¶
type Any struct {
// contains filtered or unexported fields
}
Any is a multi-producer, multi-consumer channel. Unlike with standard channels, consumers are not guaranteed to be running on a different goroutine, so emitting a signal may or may not be synchronous or asynchronous depending on the underlying API implementation. Any number of variant.Any values can be sent in a single send operation.
Also known as a Pub/Sub and/or message queue.
var Nil Any
Nil reference value, do not modify.
func Via ¶
func Via(impl API, state complex128) Any
Via creates a new signal from the specified API implementation and state.
func (*Any) Attach ¶
Attach connects this signal to the specified [Callable.Function] A signal can only be connected once to the same [Callable.Function]. If the signal is already connected, returns [Error.InvalidParameter]
type Hexa ¶
Hexa of values that can be signaled, add this as a field inside a [classdb.Extension] to register it as a signal.
type Pair ¶
Pair of values that can be signaled, add this as a field inside a [classdb.Extension] to register it as a signal.
type Quad ¶
Quad of values that can be signaled, add this as a field inside a [classdb.Extension] to register it as a signal.
type Quin ¶
Quin of values that can be signaled, add this as a field inside a [classdb.Extension] to register it as a signal.
type Solo ¶
Solo value that can be signaled, add this as a field inside a [classdb.Extension] to register it as a signal.