A simple promise library for .NET
var promise = new Promise<string>((fulfill, failure) =>
{
var response, error = API.Call("");
if (error != null)
{
failure(error);
}
else
{
fulfill(response);
}
});
Promise<int> promise = Promise.Of(3);
Promise<int> promise = Promise.Pending<int>();
if (pass)
promise.Fullfil(3);
else
promise.Reject(new Exception());
Promise.Of(3)
.Then(x => x++)
.Then(x => x++)
.Then(x => x++);
Promise.Of("Three")
.Then(x => double.Parse(x))
.Catch(e => Console.WriteLine(e.Message);
- Timeout
All
Always
Race
- Support
Then
andCatch
on aPromiseQueue