Class ReactiveExtensions
- Namespace
- ReactiveUI.Extensions
- Assembly
- ReactiveUI.Extensions.dll
Extension methods for System.
- Inheritance
-
Reactive
Extensions
Methods
AsSignal<T>(IObservable<T>)
Change the source observable type to System.
Parameters
observableIObservable<T>The observable to convert.
Returns
- IObservable<Unit>
The signal.
Type Parameters
TThe current type of the observable.
BufferUntil(IObservable<char>, char, char)
Buffers until Start char and End char are found.
public static IObservable<string> BufferUntil(this IObservable<char> @this, char startsWith, char endsWith)
Parameters
thisIObservable<char>The source observable of characters.
startsWithcharThe starting delimiter.
endsWithcharThe ending delimiter.
Returns
- IObservable<string>
A sequence of buffered strings including the start and end delimiters.
BufferUntilIdle<T>(IObservable<T>, TimeSpan, IScheduler?)
Emit a batch when the stream goes quiet.
public static IObservable<IList<T>> BufferUntilIdle<T>(this IObservable<T> source, TimeSpan idleTime, IScheduler? scheduler = null)
Parameters
sourceIObservable<T>The source.
idleTimeTimeSpan The idle time.
schedulerISchedulerThe scheduler.
Returns
- IObservable<IList<T>>
A sequence of buffered lists.
Type Parameters
TThe type of the elements in the source sequence.
BufferUntilInactive<T>(IObservable<T>, TimeSpan, IScheduler?)
Buffers items until inactivity period elapses then emits and resets buffer.
public static IObservable<IList<T>> BufferUntilInactive<T>(this IObservable<T> source, TimeSpan inactivityPeriod, IScheduler? scheduler = null)
Parameters
sourceIObservable<T>Source sequence.
inactivityPeriodTimeSpan Inactivity period.
schedulerISchedulerScheduler.
Returns
- IObservable<IList<T>>
Sequence of buffered lists.
Type Parameters
TElement type.
CatchAndReturn<T>(IObservable<T>, T)
Catches any error and returns a fallback value then completes.
Parameters
sourceIObservable<T>Source sequence.
fallbackTFallback value.
Returns
- IObservable<T>
Sequence producing either original values or fallback on error then completing.
Type Parameters
TElement type.
CatchAndReturn<T, TException>(IObservable<T>, Func<TException, T>)
Catches a specific exception type mapping it to a fallback value.
public static IObservable<T> CatchAndReturn<T, TException>(this IObservable<T> source, Func<TException, T> fallbackFactory) where TException : Exception
Parameters
sourceIObservable<T>Source sequence.
fallbackFactoryFunc<TException, T>Factory producing fallback from the exception.
Returns
- IObservable<T>
Recovered sequence.
Type Parameters
TElement type.
TExceptionException type.
CatchIgnore<TSource>(IObservable<TSource?>)
Catch exception and return Observable.Empty.
Parameters
sourceIObservable<TSource>The source.
Returns
- IObservable<TSource>
A sequence that ignores errors and completes.
Type Parameters
TSourceThe type of the source.
CatchIgnore<TSource, TException>(IObservable<TSource?>, Action<TException>)
Catch exception and return Observable.Empty.
public static IObservable<TSource?> CatchIgnore<TSource, TException>(this IObservable<TSource?> source, Action<TException> errorAction) where TException : Exception
Parameters
sourceIObservable<TSource>The source.
errorActionAction<TException>The error action.
Returns
- IObservable<TSource>
A sequence that invokes
errorActionon error and completes.
Type Parameters
TSourceThe type of the source.
TExceptionThe type of the exception.
CombineLatestValuesAreAllFalse(IEnumerable<IObservable<bool>>)
Latest values of each sequence are all false.
public static IObservable<bool> CombineLatestValuesAreAllFalse(this IEnumerable<IObservable<bool>> sources)
Parameters
sourcesIEnumerable<IObservable<bool>>The sources.
Returns
- IObservable<bool>
A sequence that emits true when all latest booleans are false.
CombineLatestValuesAreAllTrue(IEnumerable<IObservable<bool>>)
Latest values of each sequence are all true.
public static IObservable<bool> CombineLatestValuesAreAllTrue(this IEnumerable<IObservable<bool>> sources)
Parameters
sourcesIEnumerable<IObservable<bool>>The sources.
Returns
- IObservable<bool>
A sequence that emits true when all latest booleans are true.
Conflate<T>(IObservable<T>, TimeSpan, IScheduler)
Applies a conflation algorithm to an observable stream. Anytime the stream OnNext twice below minimumUpdatePeriod, the second update gets delayed to respect the minimumUpdatePeriod. If more than 2 updates happen, only the last update is pushed.
public static IObservable<T> Conflate<T>(this IObservable<T> source, TimeSpan minimumUpdatePeriod, IScheduler scheduler)
Parameters
sourceIObservable<T>The stream.
minimumUpdatePeriodTimeSpan Minimum delay between two updates.
schedulerISchedulerScheduler to publish updates.
Returns
- IObservable<T>
The conflated stream.
Type Parameters
TThe type.
DebounceImmediate<T>(IObservable<T>, TimeSpan, IScheduler?)
Debounces with an immediate first emission then standard debounce behavior.
public static IObservable<T> DebounceImmediate<T>(this IObservable<T> source, TimeSpan dueTime, IScheduler? scheduler = null)
Parameters
sourceIObservable<T>Source sequence.
dueTimeTimeSpan Debounce time.
schedulerISchedulerScheduler (optional).
Returns
- IObservable<T>
Debounced sequence.
Type Parameters
TElement type.
DebounceUntil<T>(IObservable<T>, TimeSpan, Func<T, bool>)
Debounce until a condition becomes true.
public static IObservable<T> DebounceUntil<T>(this IObservable<T> source, TimeSpan debounce, Func<T, bool> condition)
Parameters
sourceIObservable<T>The source.
debounceTimeSpan The debounce.
conditionFunc<T, bool>The condition.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
DetectStale<T>(IObservable<T>, TimeSpan, IScheduler)
Detects when a stream becomes inactive for some period of time.
public static IObservable<IStale<T>> DetectStale<T>(this IObservable<T> source, TimeSpan stalenessPeriod, IScheduler scheduler)
Parameters
sourceIObservable<T>source stream.
stalenessPeriodTimeSpan If source stream does not OnNext any update during this period, it is declared stale.
schedulerISchedulerThe scheduler.
Returns
- IObservable<IStale<T>>
Observable stale markers or updates.
Type Parameters
Tupdate type.
DoOnDispose<T>(IObservable<T>, Action)
Executes an action when subscription is disposed.
Parameters
sourceIObservable<T>Source sequence.
disposeActionActionAction to run on dispose.
Returns
- IObservable<T>
Original sequence with dispose side-effect.
Type Parameters
TElement type.
DoOnSubscribe<T>(IObservable<T>, Action)
Executes an action at subscription time.
Parameters
sourceIObservable<T>Source sequence.
actionActionAction to run on subscribe.
Returns
- IObservable<T>
Original sequence with subscribe side-effect.
Type Parameters
TElement type.
DropIfBusy<T>(IObservable<T>, Func<T, Task>)
Drop values when the previous async operation is still running.
Parameters
sourceIObservable<T>The source.
asyncActionFunc<T, Task>The asynchronous action.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Filter(IObservable<string>, string)
Filters strings by regex.
Parameters
sourceIObservable<string>Source sequence.
regexPatternstringRegex pattern.
Returns
- IObservable<string>
Filtered sequence.
ForEach<T>(IObservable<IEnumerable<T>>, IScheduler?)
Flattens a sequence of enumerables into individual values.
public static IObservable<T> ForEach<T>(this IObservable<IEnumerable<T>> source, IScheduler? scheduler = null)
Parameters
sourceIObservable<IEnumerable<T>>Source of enumerables.
schedulerISchedulerScheduler (optional).
Returns
- IObservable<T>
A flattened observable.
Type Parameters
TElement type.
FromArray<T>(IEnumerable<T>, IScheduler?)
Emits each element of an IEnumerable.
Parameters
sourceIEnumerable<T>Source enumerable.
schedulerISchedulerScheduler (optional).
Returns
- IObservable<T>
Observable of elements.
Type Parameters
TElement type.
GetMax<T>(IObservable<T?>, params IObservable<T?>[])
Gets the maximum from all sources.
public static IObservable<T?> GetMax<T>(this IObservable<T?> @this, params IObservable<T?>[] sources) where T : struct
Parameters
thisIObservable<T?>The first observable.
sourcesIObservable<T?>[]Other sources.
Returns
- IObservable<T?>
A sequence emitting the maximum of the latest values.
Type Parameters
TThe Value Type.
GetMin<T>(IObservable<T?>, params IObservable<T?>[])
Gets the minimum from all sources.
public static IObservable<T?> GetMin<T>(this IObservable<T?> @this, params IObservable<T?>[] sources) where T : struct
Parameters
thisIObservable<T?>The first observable.
sourcesIObservable<T?>[]Other sources.
Returns
- IObservable<T?>
A sequence emitting the minimum of the latest values.
Type Parameters
TThe Value Type.
Heartbeat<T>(IObservable<T>, TimeSpan, IScheduler)
Injects heartbeats in a stream when the source stream becomes quiet.
public static IObservable<IHeartbeat<T>> Heartbeat<T>(this IObservable<T> source, TimeSpan heartbeatPeriod, IScheduler scheduler)
Parameters
sourceIObservable<T>Source stream.
heartbeatPeriodTimeSpan Period between heartbeats.
schedulerISchedulerScheduler.
Returns
- IObservable<IHeartbeat<T>>
Observable heartbeat values.
Type Parameters
TUpdate type.
LatestOrDefault<T>(IObservable<T>, T)
Emit the latest value or a default if none exists.
Parameters
sourceIObservable<T>The source.
defaultValueTThe default value.
Returns
- IObservable<T>
A sequence that emits the latest value or the default.
Type Parameters
TThe type of the source.
LogErrors<T>(IObservable<T>, Action<Exception>)
Logs the errors. Inline error logging without terminating the stream.
Parameters
sourceIObservable<T>The source.
loggerAction<Exception>The logger.
Returns
- IObservable<T>
A sequence that logs errors.
Type Parameters
TThe type of the source.
Not(IObservable<bool>)
Emits the boolean negation of the source sequence.
Parameters
sourceIObservable<bool>Boolean source.
Returns
- IObservable<bool>
Negated boolean sequence.
ObserveOnIf<T>(IObservable<T>, bool, IScheduler)
Conditionally switch schedulers.
public static IObservable<T> ObserveOnIf<T>(this IObservable<T> source, bool condition, IScheduler scheduler)
Parameters
sourceIObservable<T>The source.
conditionboolif set to
true[condition].schedulerISchedulerThe scheduler.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ObserveOnIf<T>(IObservable<T>, bool, IScheduler, IScheduler)
Conditionally switch schedulers.
public static IObservable<T> ObserveOnIf<T>(this IObservable<T> source, bool condition, IScheduler trueScheduler, IScheduler falseScheduler)
Parameters
sourceIObservable<T>The source.
conditionboolif set to
true[condition].trueSchedulerISchedulerThe true scheduler.
falseSchedulerISchedulerThe false scheduler.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ObserveOnIf<T>(IObservable<T>, IObservable<bool>, IScheduler)
Conditionally switch schedulers based on a reactive condition.
public static IObservable<T> ObserveOnIf<T>(this IObservable<T> source, IObservable<bool> condition, IScheduler scheduler)
Parameters
sourceIObservable<T>The source.
conditionIObservable<bool>The reactive condition.
schedulerISchedulerThe scheduler to use when condition is true.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ObserveOnIf<T>(IObservable<T>, IObservable<bool>, IScheduler, IScheduler)
Conditionally switch schedulers based on a reactive condition.
public static IObservable<T> ObserveOnIf<T>(this IObservable<T> source, IObservable<bool> condition, IScheduler trueScheduler, IScheduler falseScheduler)
Parameters
sourceIObservable<T>The source.
conditionIObservable<bool>The reactive condition.
trueSchedulerISchedulerThe scheduler to use when condition is true.
falseSchedulerISchedulerThe scheduler to use when condition is false.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ObserveOnSafe<TSource>(IObservable<TSource>, IScheduler?)
If the scheduler is not null observes on that scheduler.
public static IObservable<TSource> ObserveOnSafe<TSource>(this IObservable<TSource> source, IScheduler? scheduler)
Parameters
sourceIObservable<TSource>Source sequence.
schedulerISchedulerScheduler to notify observers on (optional).
Returns
- IObservable<TSource>
The source sequence whose callbacks happen on the specified scheduler.
Type Parameters
TSourceElement type.
OnErrorRetry<TSource>(IObservable<TSource?>)
Repeats the source until it terminates successfully (alias of Retry).
Parameters
sourceIObservable<TSource>Source sequence.
Returns
- IObservable<TSource>
Retried sequence.
Type Parameters
TSourceElement type.
OnErrorRetry<TSource, TException>(IObservable<TSource?>, Action<TException>)
When caught exception, do onError action and repeat observable sequence.
public static IObservable<TSource?> OnErrorRetry<TSource, TException>(this IObservable<TSource?> source, Action<TException> onError) where TException : Exception
Parameters
sourceIObservable<TSource>The source.
onErrorAction<TException>The on error.
Returns
- IObservable<TSource>
A sequence that retries on error with optional delay.
Type Parameters
TSourceThe type of the source.
TExceptionThe type of the exception.
OnErrorRetry<TSource, TException>(IObservable<TSource?>, Action<TException>, int)
When caught exception, do onError action and repeat observable sequence during within retryCount.
public static IObservable<TSource?> OnErrorRetry<TSource, TException>(this IObservable<TSource?> source, Action<TException> onError, int retryCount) where TException : Exception
Parameters
sourceIObservable<TSource>The source.
onErrorAction<TException>The on error.
retryCountintThe retry count.
Returns
- IObservable<TSource>
A sequence that retries on error with optional delay.
Type Parameters
TSourceThe type of the source.
TExceptionThe type of the exception.
OnErrorRetry<TSource, TException>(IObservable<TSource?>, Action<TException>, int, TimeSpan)
When caught exception, do onError action and repeat observable sequence after delay time during within retryCount.
public static IObservable<TSource?> OnErrorRetry<TSource, TException>(this IObservable<TSource?> source, Action<TException> onError, int retryCount, TimeSpan delay) where TException : Exception
Parameters
sourceIObservable<TSource>The source.
onErrorAction<TException>The on error.
retryCountintThe retry count.
delayTimeSpan The delay.
Returns
- IObservable<TSource>
A sequence that retries on error with optional delay.
Type Parameters
TSourceThe type of the source.
TExceptionThe type of the exception.
OnErrorRetry<TSource, TException>(IObservable<TSource?>, Action<TException>, int, TimeSpan, IScheduler)
When caught exception, do onError action and repeat observable sequence after delay time(work on delayScheduler) during within retryCount.
public static IObservable<TSource?> OnErrorRetry<TSource, TException>(this IObservable<TSource?> source, Action<TException> onError, int retryCount, TimeSpan delay, IScheduler delayScheduler) where TException : Exception
Parameters
sourceIObservable<TSource>The source.
onErrorAction<TException>The on error.
retryCountintThe retry count.
delayTimeSpan The delay.
delaySchedulerISchedulerThe delay scheduler.
Returns
- IObservable<TSource>
A sequence that retries on error with optional delay.
Type Parameters
TSourceThe type of the source.
TExceptionThe type of the exception.
OnErrorRetry<TSource, TException>(IObservable<TSource?>, Action<TException>, TimeSpan)
When caught exception, do onError action and repeat observable sequence after delay time.
public static IObservable<TSource?> OnErrorRetry<TSource, TException>(this IObservable<TSource?> source, Action<TException> onError, TimeSpan delay) where TException : Exception
Parameters
sourceIObservable<TSource>The source.
onErrorAction<TException>The on error.
delayTimeSpan The delay.
Returns
- IObservable<TSource>
A sequence that retries on error with optional delay.
Type Parameters
TSourceThe type of the source.
TExceptionThe type of the exception.
OnNext<T>(IObserver<T?>, params T?[])
Pushes multiple values to an observer.
Parameters
observerIObserver<T>Observer to push to.
eventsT[]Values to push.
Type Parameters
TType of value.
Pairwise<T>(IObservable<T>)
Emit (previous, current) pairs.
Parameters
sourceIObservable<T>The source.
Returns
- IObservable<(T Previous, T Current)>
An IObservable of (T Previous, T Current).
Type Parameters
TThe type.
Partition<T>(IObservable<T>, Func<T, bool>)
Partitions a sequence into two based on predicate.
public static (IObservable<T> True, IObservable<T> False) Partition<T>(this IObservable<T> source, Func<T, bool> predicate)
Parameters
sourceIObservable<T>Source sequence.
predicateFunc<T, bool>Predicate.
Returns
- (IObservable<T> True, IObservable<T> False)
Tuple of (trueSequence, falseSequence).
Type Parameters
TElement type.
ReplayLastOnSubscribe<T>(IObservable<T>, T)
Always replay the last value, even if the source hasn’t produced one yet.
Parameters
sourceIObservable<T>The source.
initialValueTThe initial value.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
RetryForeverWithDelay<T>(IObservable<T>, TimeSpan)
Retries the forever with delay.
Parameters
sourceIObservable<T>The source.
delayTimeSpan The delay.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
RetryWithBackoff<T>(IObservable<T>, int, TimeSpan, double, TimeSpan?, IScheduler?)
Retries with exponential backoff.
public static IObservable<T> RetryWithBackoff<T>(this IObservable<T> source, int maxRetries, TimeSpan initialDelay, double backoffFactor = 2, TimeSpan? maxDelay = null, IScheduler? scheduler = null)
Parameters
sourceIObservable<T>Source sequence.
maxRetriesintMaximum number of retries.
initialDelayTimeSpan Initial backoff delay.
backoffFactordoubleMultiplier for each retry (default 2).
maxDelayTimeSpan ?Optional maximum delay.
schedulerISchedulerScheduler (optional).
Returns
- IObservable<T>
Retried sequence with backoff.
Type Parameters
TElement type.
RetryWithDelay<T>(IObservable<T>, int, Func<int, TimeSpan>)
Retry with exponential.
public static IObservable<T> RetryWithDelay<T>(this IObservable<T> source, int retryCount, Func<int, TimeSpan> delaySelector)
Parameters
sourceIObservable<T>The source.
retryCountintThe retry count.
delaySelectorFunc<int, TimeSpan >The delay selector.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
RetryWithFixedDelay<T>(IObservable<T>, int, TimeSpan)
Retry with fixed backoff.
public static IObservable<T> RetryWithFixedDelay<T>(this IObservable<T> source, int retryCount, TimeSpan delay)
Parameters
sourceIObservable<T>The source.
retryCountintThe retry count.
delayTimeSpan The delay.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
SampleLatest<T>(IObservable<T>, IObservable<object>)
Sample the latest value whenever a trigger fires.
public static IObservable<T> SampleLatest<T>(this IObservable<T> source, IObservable<object> trigger)
Parameters
sourceIObservable<T>The source.
triggerIObservable<object>The trigger.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ScanWithInitial<TSource, TAccumulate>(IObservable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>)
Scan that always emits the initial value first.
public static IObservable<TAccumulate> ScanWithInitial<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate initial, Func<TAccumulate, TSource, TAccumulate> accumulator)
Parameters
sourceIObservable<TSource>The source.
initialTAccumulateThe initial.
accumulatorFunc<TAccumulate, TSource, TAccumulate>The accumulator.
Returns
- IObservable<TAccumulate>
An IObservable of TAccumulate.
Type Parameters
TSourceThe type of the source.
TAccumulateThe type of the accumulate.
ScheduleSafe(IScheduler?, Action)
Schedules an action immediately if scheduler null, else on scheduler.
Parameters
schedulerISchedulerScheduler.
actionActionAction.
Returns
- IDisposable
Disposable for the scheduled action.
ScheduleSafe(IScheduler?, TimeSpan, Action)
Schedules an action after a due time.
Parameters
Returns
- IDisposable
Disposable for the scheduled action.
Schedule<T>(IObservable<T>, DateTimeOffset, IScheduler)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this IObservable<T> source, DateTimeOffset dueTime, IScheduler scheduler)
Parameters
sourceIObservable<T>The value.
dueTimeDateTime Offset The due time.
schedulerISchedulerThe scheduler.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(IObservable<T>, DateTimeOffset, IScheduler, Action<T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this IObservable<T> source, DateTimeOffset dueTime, IScheduler scheduler, Action<T> action)
Parameters
sourceIObservable<T>The value.
dueTimeDateTime Offset The due time.
schedulerISchedulerThe scheduler.
actionAction<T>The action.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(IObservable<T>, IScheduler, Func<T, T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this IObservable<T> source, IScheduler scheduler, Func<T, T> function)
Parameters
sourceIObservable<T>The value.
schedulerISchedulerThe scheduler.
functionFunc<T, T>The function.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(IObservable<T>, TimeSpan, IScheduler)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this IObservable<T> source, TimeSpan dueTime, IScheduler scheduler)
Parameters
sourceIObservable<T>The value.
dueTimeTimeSpan The due time.
schedulerISchedulerThe scheduler.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(IObservable<T>, TimeSpan, IScheduler, Action<T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this IObservable<T> source, TimeSpan dueTime, IScheduler scheduler, Action<T> action)
Parameters
sourceIObservable<T>The value.
dueTimeTimeSpan The due time.
schedulerISchedulerThe scheduler.
actionAction<T>The action.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(IObservable<T>, TimeSpan, IScheduler, Func<T, T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this IObservable<T> source, TimeSpan dueTime, IScheduler scheduler, Func<T, T> function)
Parameters
sourceIObservable<T>The value.
dueTimeTimeSpan The due time.
schedulerISchedulerThe scheduler.
functionFunc<T, T>The function.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(T, DateTimeOffset, IScheduler)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this T value, DateTimeOffset dueTime, IScheduler scheduler)
Parameters
valueTThe value.
dueTimeDateTime Offset The due time.
schedulerISchedulerThe scheduler.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(T, DateTimeOffset, IScheduler, Action<T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this T value, DateTimeOffset dueTime, IScheduler scheduler, Action<T> action)
Parameters
valueTThe value.
dueTimeDateTime Offset The due time.
schedulerISchedulerThe scheduler.
actionAction<T>The action.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(T, IScheduler, Func<T, T>)
Schedules the specified due time.
Parameters
valueTThe value.
schedulerISchedulerThe scheduler.
functionFunc<T, T>The function.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(T, TimeSpan, IScheduler)
Schedules a single value after a delay.
Parameters
valueTValue.
dueTimeTimeSpan Delay.
schedulerISchedulerScheduler.
Returns
- IObservable<T>
Observable that emits the value.
Type Parameters
TValue type.
Schedule<T>(T, TimeSpan, IScheduler, Action<T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this T value, TimeSpan dueTime, IScheduler scheduler, Action<T> action)
Parameters
valueTThe value.
dueTimeTimeSpan The due time.
schedulerISchedulerThe scheduler.
actionAction<T>The action.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Schedule<T>(T, TimeSpan, IScheduler, Func<T, T>)
Schedules the specified due time.
public static IObservable<T> Schedule<T>(this T value, TimeSpan dueTime, IScheduler scheduler, Func<T, T> function)
Parameters
valueTThe value.
dueTimeTimeSpan The due time.
schedulerISchedulerThe scheduler.
functionFunc<T, T>The function.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
SelectAsyncConcurrent<TSource, TResult>(IObservable<TSource>, Func<TSource, Task<TResult>>, int)
Projects each element to a task with limited concurrency.
public static IObservable<TResult> SelectAsyncConcurrent<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> selector, int maxConcurrency)
Parameters
sourceIObservable<TSource>Source sequence.
selectorFunc<TSource, Task<TResult>>Task selector.
maxConcurrencyintMax concurrency.
Returns
- IObservable<TResult>
Merged sequence of task results.
Type Parameters
TSourceSource type.
TResultResult type.
SelectAsyncSequential<TSource, TResult>(IObservable<TSource>, Func<TSource, Task<TResult>>)
Projects each element to a task executed sequentially.
public static IObservable<TResult> SelectAsyncSequential<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> selector)
Parameters
sourceIObservable<TSource>Source sequence.
selectorFunc<TSource, Task<TResult>>Task selector.
Returns
- IObservable<TResult>
Sequence of results preserving order.
Type Parameters
TSourceSource element type.
TResultResult type.
SelectAsync<TSource, TResult>(IObservable<TSource>, Func<TSource, CancellationToken, Task<TResult>>)
Maps values to async operations without losing ordering or cancellation semantics.
public static IObservable<TResult> SelectAsync<TSource, TResult>(this IObservable<TSource> source, Func<TSource, CancellationToken, Task<TResult>> asyncSelector)
Parameters
sourceIObservable<TSource>The source.
asyncSelectorFunc<TSource, CancellationToken , Task<TResult>>The asynchronous selector.
Returns
- IObservable<TResult>
An IObservable of TResult.
Type Parameters
TSourceThe type of the source.
TResultThe type of the result.
SelectAsync<TSource, TResult>(IObservable<TSource>, Func<TSource, Task<TResult>>)
Maps values to async operations without losing ordering or cancellation semantics.
public static IObservable<TResult> SelectAsync<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> asyncSelector)
Parameters
sourceIObservable<TSource>The source.
asyncSelectorFunc<TSource, Task<TResult>>The asynchronous selector.
Returns
- IObservable<TResult>
An IObservable of TResult.
Type Parameters
TSourceThe type of the source.
TResultThe type of the result.
SelectLatestAsync<TSource, TResult>(IObservable<TSource>, Func<TSource, Task<TResult>>)
Projects each element to a task but only latest result is emitted.
public static IObservable<TResult> SelectLatestAsync<TSource, TResult>(this IObservable<TSource> source, Func<TSource, Task<TResult>> selector)
Parameters
sourceIObservable<TSource>Source sequence.
selectorFunc<TSource, Task<TResult>>Task selector.
Returns
- IObservable<TResult>
Sequence of latest task results.
Type Parameters
TSourceSource type.
TResultResult type.
Shuffle<T>(IObservable<T[]>)
Randomly shuffles arrays emitted by the source.
Parameters
sourceIObservable<T[]>Source array sequence.
Returns
- IObservable<T[]>
Sequence of shuffled arrays (in-place).
Type Parameters
TArray element type.
SkipWhileNull<T>(IObservable<T?>)
Skip null values until the first non-null appears.
Parameters
sourceIObservable<T>The source.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
Start(Action, IScheduler?)
Invokes the action asynchronously surfacing the result through a Unit observable.
Parameters
actionActionAction to run.
schedulerISchedulerScheduler (optional).
Returns
- IObservable<Unit>
A sequence producing Unit upon completion.
Start<TResult>(Func<TResult>, IScheduler?)
Invokes the specified function asynchronously surfacing the result.
Parameters
functionFunc<TResult>Function to run.
schedulerISchedulerScheduler.
Returns
- IObservable<TResult>
A sequence producing the function result.
Type Parameters
TResultResult type.
SubscribeAsync<T>(IObservable<T>, Func<T, Task>)
Subscribes allowing asynchronous operations to be executed without blocking the source.
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SubscribeAsync<T>(IObservable<T>, Func<T, Task>, Action)
Subscribes allowing asynchronous operations to be executed without blocking the source.
public static IDisposable SubscribeAsync<T>(this IObservable<T> source, Func<T, Task> onNext, Action onCompleted)
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
onCompletedActionThe on completed.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SubscribeAsync<T>(IObservable<T>, Func<T, Task>, Action<Exception>)
Subscribes allowing asynchronous operations to be executed without blocking the source.
public static IDisposable SubscribeAsync<T>(this IObservable<T> source, Func<T, Task> onNext, Action<Exception> onError)
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
onErrorAction<Exception>The on error.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SubscribeAsync<T>(IObservable<T>, Func<T, Task>, Action<Exception>, Action)
Subscribes allowing asynchronous operations to be executed without blocking the source.
public static IDisposable SubscribeAsync<T>(this IObservable<T> source, Func<T, Task> onNext, Action<Exception> onError, Action onCompleted)
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
onErrorAction<Exception>The on error.
onCompletedActionThe on completed.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SubscribeSynchronous<T>(IObservable<T>, Func<T, Task>)
Subscribes an element handler to an observable sequence synchronously.
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SubscribeSynchronous<T>(IObservable<T>, Func<T, Task>, Action)
Subscribes an element handler and a completion handler to an observable sequence synchronously.
public static IDisposable SubscribeSynchronous<T>(this IObservable<T> source, Func<T, Task> onNext, Action onCompleted)
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
onCompletedActionAction to invoke upon graceful termination of the observable sequence.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
Exceptions
- Argument
Null Exception sourceoronNextoronCompletedisnull.
SubscribeSynchronous<T>(IObservable<T>, Func<T, Task>, Action<Exception>)
Subscribes an element handler and an exception handler to an observable sequence synchronously.
public static IDisposable SubscribeSynchronous<T>(this IObservable<T> source, Func<T, Task> onNext, Action<Exception> onError)
Parameters
sourceIObservable<T>Observable sequence to subscribe to.
onNextFunc<T, Task>Action to invoke for each element in the observable sequence.
onErrorAction<Exception>Action to invoke upon exceptional termination of the observable sequence.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SubscribeSynchronous<T>(IObservable<T>, Func<T, Task>, Action<Exception>, Action)
Subscribes to the specified source synchronously.
public static IDisposable SubscribeSynchronous<T>(this IObservable<T> source, Func<T, Task> onNext, Action<Exception> onError, Action onCompleted)
Parameters
sourceIObservable<T>The source.
onNextFunc<T, Task>The on next.
onErrorAction<Exception>The on error.
onCompletedActionThe on completed.
Returns
- IDisposable
IDisposable object used to unsubscribe from the observable sequence.
Type Parameters
TThe type of the elements in the source sequence.
SwitchIfEmpty<T>(IObservable<T>, IObservable<T>)
Provide a fallback observable if the source completes without emitting.
Parameters
sourceIObservable<T>The source.
fallbackIObservable<T>The fallback.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
SyncTimer(TimeSpan)
Synchronized timer all instances of this with the same TimeSpan use the same timer.
Parameters
timeSpanTimeSpan The time span.
Returns
- IObservable<Date
Time > An observable sequence producing the shared DateTime ticks.
SynchronizeAsync<T>(IObservable<T>)
Synchronizes the asynchronous operations in downstream operations. Use SubscribeSynchronus instead for a simpler version. Call Sync.Dispose() to release the lock in the downstream methods.
public static IObservable<(T Value, IDisposable Sync)> SynchronizeAsync<T>(this IObservable<T> source)
Parameters
sourceIObservable<T>The source.
Returns
- IObservable<(T Value, IDisposable Sync)>
An Observable of T and a release mechanism.
Type Parameters
TThe type of the elements in the source sequence.
SynchronizeSynchronous<T>(IObservable<T>)
Wraps values with a synchronization disposable that completes when disposed.
public static IObservable<(T Value, IDisposable Sync)> SynchronizeSynchronous<T>(this IObservable<T> source)
Parameters
sourceIObservable<T>Source sequence.
Returns
- IObservable<(T Value, IDisposable Sync)>
Sequence of (value, sync handle).
Type Parameters
TElement type.
TakeUntil<TSource>(IObservable<TSource>, Func<TSource, bool>)
Takes elements until predicate returns true for an element (inclusive) then completes.
public static IObservable<TSource> TakeUntil<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
Parameters
sourceIObservable<TSource>Source sequence.
predicateFunc<TSource, bool>Predicate for completion.
Returns
- IObservable<TSource>
Sequence that completes when predicate satisfied.
Type Parameters
TSourceElement type.
ThrottleDistinct<T>(IObservable<T>, TimeSpan)
Throttle but only emit when the value actually changes.
Parameters
sourceIObservable<T>The source.
throttleTimeSpan The throttle.
Returns
- IObservable<T>
A throttled distinct sequence.
Type Parameters
TElement type.
ThrottleDistinct<T>(IObservable<T>, TimeSpan, IScheduler)
Throttle but only emit when the value actually changes.
public static IObservable<T> ThrottleDistinct<T>(this IObservable<T> source, TimeSpan throttle, IScheduler scheduler)
Parameters
sourceIObservable<T>The source.
throttleTimeSpan The throttle.
schedulerISchedulerThe scheduler.
Returns
- IObservable<T>
A throttled distinct sequence.
Type Parameters
TElement type.
ThrottleFirst<T>(IObservable<T>, TimeSpan, IScheduler?)
Emits only the first value in each time window.
public static IObservable<T> ThrottleFirst<T>(this IObservable<T> source, TimeSpan window, IScheduler? scheduler = null)
Parameters
sourceIObservable<T>Source sequence.
windowTimeSpan Time window.
schedulerISchedulerScheduler (optional).
Returns
- IObservable<T>
Throttle-first sequence.
Type Parameters
TElement type.
ThrottleOnScheduler<T>(IObservable<T>, TimeSpan, IScheduler)
Throttles the on scheduler.
public static IObservable<T> ThrottleOnScheduler<T>(this IObservable<T> source, TimeSpan timeSpan, IScheduler scheduler)
Parameters
sourceIObservable<T>The source.
timeSpanTimeSpan The time span.
schedulerISchedulerThe scheduler.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ThrottleUntilTrue<T>(IObservable<T>, TimeSpan, Func<T, bool>)
Throttle until a predicate becomes true.
public static IObservable<T> ThrottleUntilTrue<T>(this IObservable<T> source, TimeSpan throttle, Func<T, bool> predicate)
Parameters
sourceIObservable<T>The source.
throttleTimeSpan The throttle.
predicateFunc<T, bool>The predicate.
Returns
- IObservable<T>
An IObservable of T.
Type Parameters
TThe type.
ToHotTask<T>(IObservable<T>)
Convert an observable to a Task that starts immediately.
Parameters
sourceIObservable<T>The source.
Returns
- Task<T>
A Task of T.
Type Parameters
TThe type.
ToPropertyObservable<T, TProperty>(T, Expression<Func<T, TProperty>>)
Convert a property getter into an observable that emits on change.
public static IObservable<TProperty> ToPropertyObservable<T, TProperty>(this T source, Expression<Func<T, TProperty>> propertyExpression) where T : INotifyPropertyChanged
Parameters
sourceTThe source.
propertyExpressionExpression<Func<T, TProperty>>The property expression.
Returns
- IObservable<TProperty>
An IObservable of TProperty.
Type Parameters
TThe type of the source.
TPropertyThe type of the property.
Exceptions
- Argument
Exception Expression must be a property.
ToReadOnlyBehavior<T>(T)
A safe wrapper around BehaviorSubject that exposes only the observable.
public static (IObservable<T> Observable, IObserver<T> Observer) ToReadOnlyBehavior<T>(T initialValue)
Parameters
initialValueTThe initial value.
Returns
- (IObservable<T> Observable, IObserver<T> Observer)
A tuple of IObservable and IObserver.
Type Parameters
TThe type.
Using<T>(T, Action<T>, IScheduler?)
Using helper with Action.
public static IObservable<Unit> Using<T>(this T obj, Action<T> action, IScheduler? scheduler = null) where T : IDisposable
Parameters
objTObject to use.
actionAction<T>Action to run.
schedulerISchedulerScheduler.
Returns
- IObservable<Unit>
Completion signal.
Type Parameters
TDisposable type.
Using<T, TResult>(T, Func<T, TResult>, IScheduler?)
Using helper with Func.
public static IObservable<TResult> Using<T, TResult>(this T obj, Func<T, TResult> function, IScheduler? scheduler = null) where T : IDisposable
Parameters
objTObject to use.
functionFunc<T, TResult>Function to invoke.
schedulerISchedulerScheduler.
Returns
- IObservable<TResult>
Observable of result.
Type Parameters
TDisposable type.
TResultResult type.
WaitUntil<T>(IObservable<T>, Func<T, bool>)
Emits the first element matching predicate then completes.
Parameters
sourceIObservable<T>Source sequence.
predicateFunc<T, bool>Predicate.
Returns
- IObservable<T>
Sequence with first matching element.
Type Parameters
TElement type.
WhereFalse(IObservable<bool>)
Filters to false values only.
Parameters
sourceIObservable<bool>Boolean source.
Returns
- IObservable<bool>
Sequence of false values.
WhereIsNotNull<T>(IObservable<T>)
Returns only values that are not null. Converts the nullability.
Parameters
observableIObservable<T>The observable that can contain nulls.
Returns
- IObservable<T>
A non nullable version of the observable that only emits valid values.
Type Parameters
TThe type of value emitted by the observable.
WhereTrue(IObservable<bool>)
Filters to true values only.
Parameters
sourceIObservable<bool>Boolean source.
Returns
- IObservable<bool>
Sequence of true values.
While(Func<bool>, Action, IScheduler?)
While construct.
public static IObservable<Unit> While(Func<bool> condition, Action action, IScheduler? scheduler = null)
Parameters
conditionFunc<bool>Condition to evaluate.
actionActionAction to execute.
schedulerISchedulerScheduler.
Returns
- IObservable<Unit>
Observable representing the loop.
WithLimitedConcurrency<T>(IEnumerable<Task<T>>, int)
Executes with limited concurrency.
public static IObservable<T> WithLimitedConcurrency<T>(this IEnumerable<Task<T>> taskFunctions, int maxConcurrency)
Parameters
taskFunctionsIEnumerable<Task<T>>Tasks to execute.
maxConcurrencyintMaximum concurrency.
Returns
- IObservable<T>
A sequence of task results.
Type Parameters
TThe result type.