Skip to content

Commit

Permalink
Updated Task Extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
RLittlesII committed Aug 21, 2018
1 parent 2ff29cb commit a1ac48a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
19 changes: 10 additions & 9 deletions src/Reactive.Extensions/ObservableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,33 +1319,34 @@ public static IObservable<TSource> Reduce<TSource>(this IObservable<TSource> sou
{
return source.Aggregate(accumulator);
}

/// <summary>
/// Returns a <see cref="Unit"/> at the completion of an observable sequence.
/// </summary>
/// <param name="this">The observable sequence that requires a return value.</param>
/// <param name="source">The observable sequence that requires a return value.</param>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public static IObservable<Unit> ToSignal<TSource>(this IObservable<TSource> @this)
public static IObservable<Unit> ToSignal<TSource>(this IObservable<TSource> source)
{
if (@this == null)
if (source == null)
{
throw new ArgumentNullException(nameof(@this));
throw new ArgumentNullException(nameof(source));
}
return @this

return source
.Select(_ => Unit.Default);
}

/// <summary>
/// Applies a filter on an observable sequence returning only items from the sequence that are not null.
/// </summary>
/// <param name="this">The source observable sequence</param>
/// <param name="source">The source observable sequence</param>
/// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
/// <returns></returns>
public static IObservable<TSource> WhereNotNull<TSource>(this IObservable<TSource> @this)
public static IObservable<TSource> WhereNotNull<TSource>(this IObservable<TSource> source)
{
return @this.Where(x => x != null);
return source.Where(x => x != null);
}
}
}
24 changes: 16 additions & 8 deletions src/Task.Extensions/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,34 @@ public static class TaskExtensions
/// <summary>
/// Continues the <see cref="Task"/> return on any <see cref="IScheduler"/> context.
/// </summary>
/// <param name="this">The this.</param>
/// <param name="task">The this.</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException">this</exception>
public static ConfiguredTaskAwaitable ContinueOnAnyContext(this Task @this)
public static ConfiguredTaskAwaitable ContinueOnAnyContext(this Task task)
{
if (@this == null) throw new ArgumentNullException(nameof(@this));
return @this.ConfigureAwait(false);
if (task == null)
{
throw new ArgumentNullException(nameof(task));
}

return task.ConfigureAwait(false);
}

/// <summary>
/// Continues the <see cref="Task"/> return on any <see cref="IScheduler"/> context.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="this">The this.</param>
/// <param name="task">The this.</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException">this</exception>
public static ConfiguredTaskAwaitable<T> ContinueOnAnyContext<T>(this Task<T> @this)
public static ConfiguredTaskAwaitable<T> ContinueOnAnyContext<T>(this Task<T> task)
{
if (@this == null) throw new ArgumentNullException(nameof(@this));
return @this.ConfigureAwait(false);
if (task == null)
{
throw new ArgumentNullException(nameof(task));
}

return task.ConfigureAwait(false);
}
}
}

0 comments on commit a1ac48a

Please sign in to comment.