diff Implab/Promise.cs @ 205:8200ab154c8a v2

Added ResetState to RunnableComponent to reset in case of failure Added StateChanged event to IRunnable Renamed Promise.SUCCESS -> Promise.Success Added Promise.FromException Renamed Bundle -> PromiseAll in PromiseExtensions
author cin
date Tue, 25 Oct 2016 17:40:33 +0300
parents 8c0b95069066
children b1e0ffdf3451
line wrap: on
line diff
--- a/Implab/Promise.cs	Tue Oct 18 17:49:54 2016 +0300
+++ b/Implab/Promise.cs	Tue Oct 25 17:40:33 2016 +0300
@@ -3,11 +3,10 @@
 
 namespace Implab {
     public class Promise : AbstractPromise, IDeferred {
-        public static readonly Promise SUCCESS;
+        public static readonly IPromise Success;
 
         static Promise() {
-            SUCCESS = new Promise();
-            SUCCESS.Resolve();
+            Success = new SuccessPromise();
         }
 
         public void Resolve() {
@@ -16,7 +15,11 @@
 
         public void Reject(Exception error) {
             SetError(error);
-        }
+        }
+
+        public static IPromise FromException(Exception exception) {
+            return new FailedPromise(exception);
+        }
     }
 }