SourceOps

ox.channels.SourceOps
trait SourceOps[+T]

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Source[T]
class Channel[T]
Self type
Source[T]

Members list

Value members

Concrete methods

def collect[U](f: PartialFunction[T, U])(using Ox, BufferCapacity): Source[U]

Applies the given mapping function f to each value received from this source, for which the function is defined, and sends the results to the returned channel. If f is not defined at a value, the value will be skipped.

Applies the given mapping function f to each value received from this source, for which the function is defined, and sends the results to the returned channel. If f is not defined at a value, the value will be skipped.

Errors from this channel are propagated to the returned channel. Any exceptions that occur when invoking f are propagated as errors to the returned channel as well.

Must be run within a scope, as a child fork is created, which receives from this source and sends the mapped values to the resulting one.

For a lazily-evaluated version, see collectAsView.

Value parameters

f

The mapping function.

Attributes

Returns

A source, onto which results of the mapping function will be sent.

def collectAsView[U](f: PartialFunction[T, U]): Source[U]

Creates a view of this source, where the results of receive will be transformed on the consumer's thread using the given function f. If the function is not defined at a value, the value will be skipped. For an eager, asynchronous version, see collect.

Creates a view of this source, where the results of receive will be transformed on the consumer's thread using the given function f. If the function is not defined at a value, the value will be skipped. For an eager, asynchronous version, see collect.

The same logic applies to receive clauses created using this source, which can be used in select.

Value parameters

f

The collecting function. Results should not be null.

Attributes

Returns

A source which is a view of this source, with the collecting function applied.

def filter(f: T => Boolean)(using Ox, BufferCapacity): Source[T]
def filterAsView(f: T => Boolean): Source[T]

Lazily-evaluated filter: Creates a view of this source, where the results of receive will be filtered on the consumer's thread using the given predicate p. For an eager, asynchronous version, see filter.

Lazily-evaluated filter: Creates a view of this source, where the results of receive will be filtered on the consumer's thread using the given predicate p. For an eager, asynchronous version, see filter.

The same logic applies to receive clauses created using this source, which can be used in select.

Value parameters

f

The predicate to use for filtering.

Attributes

Returns

A source which is a view of this source, with the filtering function applied.

def map[U](f: T => U)(using Ox, BufferCapacity): Source[U]

Applies the given mapping function f to each value received from this source, and sends the results to the returned channel.

Applies the given mapping function f to each value received from this source, and sends the results to the returned channel.

Errors from this channel are propagated to the returned channel. Any exceptions that occur when invoking f are propagated as errors to the returned channel as well.

Must be run within a scope, as a child fork is created, which receives from this source and sends the mapped values to the resulting one.

For a lazily-evaluated version, see mapAsView.

Value parameters

f

The mapping function.

Attributes

Returns

A source, onto which results of the mapping function will be sent.

def mapAsView[U](f: T => U): Source[U]

Lazily-evaluated map: creates a view of this source, where the results of receive will be transformed on the consumer's thread using the given function f. For an eager, asynchronous version, see map.

Lazily-evaluated map: creates a view of this source, where the results of receive will be transformed on the consumer's thread using the given function f. For an eager, asynchronous version, see map.

The same logic applies to receive clauses created using this source, which can be used in select.

Value parameters

f

The mapping function. Results should not be null.

Attributes

Returns

A source which is a view of this source, with the mapping function applied.

def tap(f: T => Unit)(using Ox, BufferCapacity): Source[T]

Applies the given consumer function f to each value received from this source.

Applies the given consumer function f to each value received from this source.

Errors from this channel are propagated to the returned channel. Any exceptions that occur when invoking f are propagated as errors to the returned channel as well.

Must be run within a scope, as a child fork is created, which receives from this source and sends the mapped values to the resulting one.

Useful for side-effects without result values, like logging and debugging. For a lazily-evaluated version, see tapAsView.

Value parameters

f

The consumer function.

Attributes

Returns

A source, which the values from the input source are passed to.

def tapAsView(f: T => Unit): Source[T]

Lazily-evaluated tap: creates a view of this source, where the results of receive will be applied to the given function f on the consumer's thread. Useful for side-effects without result values, like logging and debugging. For an eager, asynchronous version, see tap.

Lazily-evaluated tap: creates a view of this source, where the results of receive will be applied to the given function f on the consumer's thread. Useful for side-effects without result values, like logging and debugging. For an eager, asynchronous version, see tap.

The same logic applies to receive clauses created using this source, which can be used in select.

Value parameters

f

The consumer function.

Attributes

Returns

A source which is a view of this source, with the consumer function applied.

def transform[U](f: (Iterator[T]) => Iterator[U])(using Ox, BufferCapacity): Source[U]