using System;
namespace Chernobyl.Extensions
{
///
/// Extension methods for the type.
///
public static class ObservableExtensions
{
///
/// Returns the as its
/// equivalent.
///
/// The type returned to the response channel.
/// The method to return as an .
/// as .
public static Action> AsAction(this Subscribe subscribe)
{
return new Action>(subscribe);
}
///
/// Projects each element of an observable into a new form using the
/// specified selector.
///
/// The type of the subscription origin.
/// The type of the subscription destination.
/// The method to receive from.
/// The method that will convert the source to
/// the result.
/// The method to receive the result from.
public static Subscribe Select(
this Subscribe subscribe, Func selector)
{
return resultCallback =>
{
var sourceCallback = resultCallback.Select(selector);
subscribe(sourceCallback);
};
}
}
}