Table of Contents

Method ListenStrong

Namespace
SodaFlow
Assembly
SodaFlow.dll

ListenStrong<T>(Stream<T>, Action<T>)

Listen for events/firings on this stream, keeping the stream alive for as long as the returned listener is reachable. A disposal of the IStrongListener from this call stops the listener. This is an OPERATIONAL mechanism for the boundary between the world of I/O and FRP.

public static IStrongListener ListenStrong<T>(this Stream<T> s, Action<T> handler)

Parameters

s Stream<T>

The stream.

handler Action<T>

The handler to run with each value the stream fires.

Returns

IStrongListener

An IStrongListener. A disposal of it stops the listener.

Type Parameters

T

The type of the stream.

Remarks

Make no assumption about the thread that calls the handler, and the handler must not block. The handler must not call Send<T>(StreamSink<T>, T) or Send<T>(CellSink<T>, T). They throw an exception, because this method is not for the definition of a new primitive.

With no disposal of the IStrongListener, the listener continues until a GC collects this stream.

This roots the stream, thus a GC cannot collect the graph behind it while the listener from this call is reachable. Use Listen<T>(Stream<T>, Action<T>) where that is not wanted.