diff Implab/PromiseReaction`1.cs @ 246:5aa9cfbe56c3 v3

missing files
author cin
date Fri, 26 Jan 2018 11:19:38 +0300
parents
children fb70574741a1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab/PromiseReaction`1.cs	Fri Jan 26 11:19:38 2018 +0300
@@ -0,0 +1,25 @@
+using System;
+
+namespace Implab {
+    public class PromiseReaction<T> : IResolvable<T> {
+        IDispatcher m_dispatcher;
+
+        Action<T> m_onFulfilledJob;
+
+        Action<Exception> m_onRejectedJob;
+
+        public void Reject(Exception error) {
+            if (m_dispatcher != null)
+                m_dispatcher.Enqueue(() => m_onRejectedJob(error));
+            else
+                m_onRejectedJob(error);
+        }
+
+        public void Resolve(T result) {
+            if (m_dispatcher != null)
+                m_dispatcher.Enqueue(() => m_onFulfilledJob(result));
+            else
+                m_onFulfilledJob(result);
+        }
+    }
+}
\ No newline at end of file