Table of Contents

Method Choose

Namespace
SodaFlow
Assembly
SodaFlow.dll

Choose<T, TResult>(Stream<T>, Func<T, Maybe<TResult>>)

Transform the stream values with a function which can give no value, and fire only the values it gives.

public static Stream<TResult> Choose<T, TResult>(this Stream<T> s, Func<T, Maybe<TResult>> f)

Parameters

s Stream<T>

The stream to transform.

f Func<T, Maybe<TResult>>

Function to apply to each value. It can make FRP logic or use Sample<T>(Cell<T>). Apart from this the function must be pure.

Returns

Stream<TResult>

A stream that fires the value from f, for each firing of s that gives one. It does not fire for the other firings.

Type Parameters

T

The type of the values fired by the stream to transform.

TResult

The type of the values fired by the returned stream.

Remarks

Maps and filters in one step. Use it for the usual condition where a test of an event is the same work as the value that goes through. Examples are a parse, a lookup, and a narrower type. This is s.Map(f).FilterSome(), with the same transaction semantics.