Table of Contents

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

s Stream<T>

The stream.

handler Action<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

T

The 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.