using System;

namespace Rowa.Observables;

public static class ObservableExtensions
{
    /// <summary>
    /// Map one observable to another type
    /// </summary>
    /// <typeparam name="TIn"></typeparam>
    /// <typeparam name="TOut"></typeparam>
    /// <param name="source"></param>
    /// <param name="map"></param>
    /// <returns></returns>
    public static IObservable<TOut> Map<TIn, TOut>(this IObservable<TIn> source, Func<TIn, TOut> map)
    {
        return new MappedObservable<TIn, TOut>(map, source);
    }

    /// <summary>
    /// Combines many observables into one
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="other"></param>
    /// <returns></returns>
    public static IObservable<T[]> Combine<T>(params IObservable<T>[] other)
    {
        return new CombineObservable<T>(other);
    }
}