Skip to content

Latest commit

 

History

History
56 lines (49 loc) · 844 Bytes

README.md

File metadata and controls

56 lines (49 loc) · 844 Bytes

IPromise

A simple promise library for .NET

Usage

Typical promise

var promise = new Promise<string>((fulfill, failure) => 
{
  var response, error = API.Call("");
  if (error != null)
  {
    failure(error);
  }
  else 
  {
    fulfill(response);
  }
});

Completed Promise

Promise<int> promise = Promise.Of(3);

Pending Promise

Promise<int> promise = Promise.Pending<int>();
if (pass)
  promise.Fullfil(3);
else
  promise.Reject(new Exception());

Then Chaining

Promise.Of(3)
  .Then(x => x++)
  .Then(x => x++)
  .Then(x => x++);

Catching Exceptions

Promise.Of("Three")
  .Then(x => double.Parse(x))
  .Catch(e => Console.WriteLine(e.Message);

Future Features

  • Timeout
  • All
  • Always
  • Race
  • Support Then and Catch on a PromiseQueue