浏览代码

Adding Start.

Bart De Smet 8 年之前
父节点
当前提交
faf9153d54
共有 1 个文件被更改,包括 47 次插入0 次删除
  1. 47 0
      AsyncRx.NET/System.Reactive.Async.Linq/System/Reactive/Linq/Operators/Start.cs

+ 47 - 0
AsyncRx.NET/System.Reactive.Async.Linq/System/Reactive/Linq/Operators/Start.cs

@@ -0,0 +1,47 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System.Reactive.Concurrency;
+
+namespace System.Reactive.Linq
+{
+    partial class AsyncObservable
+    {
+        public static IAsyncObservable<TSource> Start<TSource>(Func<TSource> function)
+        {
+            if (function == null)
+                throw new ArgumentNullException(nameof(function));
+
+            return ToAsync(function)();
+        }
+
+        public static IAsyncObservable<TSource> Start<TSource>(Func<TSource> function, IAsyncScheduler scheduler)
+        {
+            if (function == null)
+                throw new ArgumentNullException(nameof(function));
+            if (scheduler == null)
+                throw new ArgumentNullException(nameof(scheduler));
+
+            return ToAsync(function, scheduler)();
+        }
+
+        public static IAsyncObservable<Unit> Start(Action action)
+        {
+            if (action == null)
+                throw new ArgumentNullException(nameof(action));
+
+            return ToAsync(action)();
+        }
+
+        public static IAsyncObservable<Unit> Start(Action action, IAsyncScheduler scheduler)
+        {
+            if (action == null)
+                throw new ArgumentNullException(nameof(action));
+            if (scheduler == null)
+                throw new ArgumentNullException(nameof(scheduler));
+
+            return ToAsync(action, scheduler)();
+        }
+    }
+}