using System; using System.Collections.Generic; using System.Text; using UniRx.Operators; namespace UniRx { public static partial class Observable { public static IObservable Synchronize(this IObservable source) { return new SynchronizeObservable(source, new object()); } public static IObservable Synchronize(this IObservable source, object gate) { return new SynchronizeObservable(source, gate); } public static IObservable ObserveOn(this IObservable source, IScheduler scheduler) { return new ObserveOnObservable(source, scheduler); } public static IObservable SubscribeOn(this IObservable source, IScheduler scheduler) { return new SubscribeOnObservable(source, scheduler); } public static IObservable DelaySubscription(this IObservable source, TimeSpan dueTime) { return new DelaySubscriptionObservable(source, dueTime, Scheduler.DefaultSchedulers.TimeBasedOperations); } public static IObservable DelaySubscription(this IObservable source, TimeSpan dueTime, IScheduler scheduler) { return new DelaySubscriptionObservable(source, dueTime, scheduler); } public static IObservable DelaySubscription(this IObservable source, DateTimeOffset dueTime) { return new DelaySubscriptionObservable(source, dueTime, Scheduler.DefaultSchedulers.TimeBasedOperations); } public static IObservable DelaySubscription(this IObservable source, DateTimeOffset dueTime, IScheduler scheduler) { return new DelaySubscriptionObservable(source, dueTime, scheduler); } public static IObservable Amb(params IObservable[] sources) { return Amb((IEnumerable>)sources); } public static IObservable Amb(IEnumerable> sources) { var result = Observable.Never(); foreach (var item in sources) { var second = item; result = result.Amb(second); } return result; } public static IObservable Amb(this IObservable source, IObservable second) { return new AmbObservable(source, second); } } }