Method ListenOnceStrong
- Namespace
- SodaFlow
- Assembly
- SodaFlow.dll
ListenOnceStrong<T>(Stream<T>, Action<T>)
Handle the first event on this stream and then automatically unregister, keeping the stream alive until that first event arrives.
public static IStrongListener ListenOnceStrong<T>(this Stream<T> s, Action<T> handler)
Parameters
sStream<T>The stream.
handlerAction<T>The handler to run with the first value this stream fires.
Returns
- IStrongListener
An IStrongListener. A disposal of it stops the listener before that first event arrives.
Type Parameters
TThe type of the stream.
Remarks
This roots the stream until that first event arrives. Thus, the handler runs when the caller discards the listener from this call. The root ends with that first event, or with an earlier Unlisten() . Use ListenOnce<T>(Stream<T>, Action<T>) where the listener must not extend the lifetime of what it monitors.