Documentation
¶
Index ¶
- func Filter[T any](ctx context.Context, ch <-chan T, fn func(T) bool) <-chan T
- func Join2[T, U any](ctx context.Context, ch1 <-chan T, ch2 <-chan U) <-chan values.Result[values.Tuple[T, U]]
- func Map[T, U any](ctx context.Context, ch <-chan T, fn func(T) U) <-chan U
- func ReceiveChanWithContext[T any](ctx context.Context, ch <-chan T) <-chan values.Result[T]
- func RecieveWithContext[T any](ctx context.Context, ch <-chan T) (T, error)
- func SendWithContext[T any](ctx context.Context, ch chan<- T, val T) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter receives every value on ch, passes it to fn, and if fn returns true, forwards that value to the returned channel. The returned channel is closed if ctx.Done() receives or ch is closed.
func Join2 ¶
func Join2[T, U any](ctx context.Context, ch1 <-chan T, ch2 <-chan U) <-chan values.Result[values.Tuple[T, U]]
Join2 takes two channels and returns one that will either receive the values of the two, or receive a values.Error if one of the following happens:
1. ctx.Done() receives before both channels receive 2. Either channel is closed at any time
THIS FUNCTION IS NOT YET IMPLEMENTED
func Map ¶
Map starts listens on ch in a background goroutine. Upon receiving a value, it calls fn(receivedValue) and sends the result to the channel this function returns.
If ch is closed or ctx.Done() receives, this function stops receiving on ch and closes the returned channel.
func ReceiveChanWithContext ¶
ReceiveChanWithContext listens on ch in the background and returns a channel that follows the following rules:
1. If ctx.Done() receives before ch does, the returned channel will receive a values.Error and then be closed 2. If ch is closed before anything else, the returned channel will receive a values.Error and then be closed 3. If ch receives a value, the returned channel will receive that value and then be closed
func RecieveWithContext ¶
ReceiveWithContext blocks until ch receives a value, is closed, or ctx.Done() receives. In the first case, this function returns the value received and a nil error. In the latter two cases, it returns the zero value of T and a descriptive, non-nil error
Types ¶
This section is empty.