You can simply define the extension method yourself by removing the Timestamped wrapper manually by calling Select and returning the Value property from the Timestamped instance:
public static IObservable<T> LogTimestampedValues<T>(this IObservable<T> source, Action<Timestamped<T>> onNext) { // Validate parameters. if (source == null) throw new ArgumentNullException("source"); if (onNext == null) throw new ArgumentNullException("onNext"); // Timestamp, call action, then unwrap. return source.Timestamp().Do(onNext).Select(t => t.Value); }
However, to be truly efficient, you really want to define an overload that accepts an IScheduler implementation and calls the Timestamp extension method overload :
public static IObservable<T> LogTimestampedValues<T>(this IObservable<T> source, Action<Timestamped<T>> onNext, IScheduler scheduler) { // Validate parameters. if (source == null) throw new ArgumentNullException("source"); if (onNext == null) throw new ArgumentNullException("onNext"); if (scheduler == null) throw new ArgumentNullException("scheduler"); // Timestamp, call action, then unwrap. return source.Timestamp(scheduler).Do(onNext).Select(t => t.Value); }
You want to do this because you may have a specific scheduler that you want to use for logging.
If you do not pass the implementation of IScheduler to, then the original extension method is nothing more than a thin shell using the Do extension method and does not give much value.
source share