diff Implab/Safe.cs @ 248:5cb4826c2c2a v3

Added awaiters to promises Added static methods to Promise Resolve, Reject, All. Updated promise helpers
author cin
date Tue, 30 Jan 2018 01:37:17 +0300
parents bdfdba6b645b
children 7c7e9ad6fe4a
line wrap: on
line diff
--- a/Implab/Safe.cs	Fri Jan 26 18:46:27 2018 +0300
+++ b/Implab/Safe.cs	Tue Jan 30 01:37:17 2018 +0300
@@ -112,9 +112,9 @@
             ArgumentNotNull(action, "action");
 
             try {
-                return Promise<T>.FromResult(action());
+                return Promise.Resolve(action());
             } catch (Exception err) {
-                return Promise<T>.FromException(err);
+                return Promise.Reject<T>(err);
             }
         }
 
@@ -124,9 +124,9 @@
 
             try {
                 action();
-                return Promise.Success;
+                return Promise.Resolve();
             } catch (Exception err) {
-                return new FailedPromise(err);
+                return Promise.Reject(err);
             }
         }
 
@@ -135,9 +135,9 @@
             ArgumentNotNull(action, "action");
 
             try {
-                return action() ?? new FailedPromise(new Exception("The action returned null"));
+                return action() ?? Promise.Reject(new Exception("The action returned null"));
             } catch (Exception err) {
-                return new FailedPromise(err);
+                return Promise.Reject(err);
             }
         }
 
@@ -149,9 +149,9 @@
             ArgumentNotNull(action, "action");
 
             try {
-                return action() ?? Promise<T>.FromException(new Exception("The action returned null"));
+                return action() ?? Promise.Reject<T>(new Exception("The action returned null"));
             } catch (Exception err) {
-                return Promise<T>.FromException(err);
+                return Promise.Reject<T>(err);
             }
         }