Table of Contents

Method Sample

Namespace
SodaFlow
Assembly
SodaFlow.dll

Sample<T>(Cell<T>)

Sample the current value of the cell.

public static T Sample<T>(this Cell<T> c)

Parameters

c Cell<T>

The cell.

Returns

T

The current value of the cell.

Type Parameters

T

The type of the cell.

Remarks

The functions that the primitives give to a stream can call this method. Those primitives are Map<T, TResult>(Stream<T>, Func<T, TResult>) , where a call here is the same as a snapshot of the cell, Snapshot<T, T1, TResult>(Stream<T>, Cell<T1>, Func<T, T1, TResult>) , Filter<T>(Stream<T>, Func<T, bool>) , and Merge<T>(Stream<T>, Stream<T>, Func<T, T, T>) .

Usually, use ListenStrong<T>(Cell<T>, Action<T>) as a replacement, thus the code keeps each update. But this method is correct in many conditions.

It can be best to use this method in an explicit transaction (using Run<T>(Func<T>) or RunVoid(Action)). For example, a c.Sample() in an explicit transaction, with a c.Updates().ListenStrong(...), captures the current value and each update. The code keeps each value between the two.