/// <summary> /// Converts a Windows Runtime asynchronous action to an observable sequence, ignoring its progress notifications. /// Each observer subscribed to the resulting observable sequence will be notified about the action's successful or exceptional completion. /// </summary> /// <typeparam name="TProgress">The type of the reported progress objects, which get ignored by this conversion.</typeparam> /// <param name="source">Asynchronous action to convert.</param> /// <returns>An observable sequence that produces a unit value when the asynchronous action completes, or propagates the exception produced by the asynchronous action.</returns> /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception> public static IObservable <Unit> ToObservable <TProgress>(this IAsyncActionWithProgress <TProgress> source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(source.ToObservable_(null)); }
/// <summary> /// Converts a Windows Runtime asynchronous action to an observable sequence, reporting its progress through the supplied progress object. /// Each observer subscribed to the resulting observable sequence will be notified about the action's successful or exceptional completion. /// </summary> /// <typeparam name="TProgress">The type of the reported progress objects.</typeparam> /// <param name="source">Asynchronous action to convert.</param> /// <param name="progress">Progress object to receive progress notifications on.</param> /// <returns>An observable sequence that produces a unit value when the asynchronous action completes, or propagates the exception produced by the asynchronous action.</returns> /// <exception cref="ArgumentNullException"><paramref name="source"/> or <paramref name="progress"/> is null.</exception> public static IObservable <Unit> ToObservable <TProgress>(this IAsyncActionWithProgress <TProgress> source, IProgress <TProgress> progress) { if (source == null) { throw new ArgumentNullException("source"); } if (progress == null) { throw new ArgumentNullException("progress"); } return(source.ToObservable_(progress)); }
/// <summary> /// Converts a Windows Runtime asynchronous action to an observable sequence reporting its progress. /// Each observer subscribed to the resulting observable sequence will be notified about the action's successful or exceptional completion. /// </summary> /// <typeparam name="TProgress">The type of the reported progress objects.</typeparam> /// <param name="source">Asynchronous action to convert.</param> /// <returns>An observable sequence that produces progress values from the asynchronous action and notifies observers about the action's completion.</returns> /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception> public static IObservable <TProgress> ToObservableProgress <TProgress>(this IAsyncActionWithProgress <TProgress> source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(Observable.Create <TProgress>(observer => { var progress = observer.ToProgress(); var src = source.ToObservable_(progress); return src.Subscribe(_ => { }, observer.OnError, observer.OnCompleted); })); }