Method ListenStrong
- Namespace
- SodaFlow
- Assembly
- SodaFlow.dll
ListenStrong<T>(Cell<T>, Action<T>)
Listen for updates to the value of this cell, keeping the cell 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 Cell<T> c, Action<T> handler)
Parameters
Returns
- IStrongListener
An IStrongListener. A disposal of it stops the listener.
Type Parameters
TThe type of the cell.
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 cell.
This roots the cell, thus a GC cannot collect the graph behind it while the listener from this call is reachable. Use Listen<T>(Cell<T>, Action<T>) where that is not wanted.