This page contains documentation for advanced Fuse features, so we have taken the liberty to tick the "Show advanced things" checkbox above for you in advance to be able to provide you with some additional information.

Uno-side Promise based on the A+ standard.

This can be used in multiple ways:

Statically

You can use the Run function to wrap whatever argument-less function you want as a Promise, like this:

bool doStuff()
{
    //stuff is done
    success = doOtherStuff();
    return success;
}

void onSuccess(bool value)
{
    //Success!
}

void onFail(Exception e)
{
    // Oh no!
}

public void DoSomeFancyStuff()
{
    var promise = Promise.Run(doStuff).Then(onSuccess, onFail);
}

Make your own promises

You can also extend Promise and handle it yourself. Simply call Resolve or Reject once you have a result or a failure. The Native Facebook login example is a good example of this being done in practice.

Notice that Resolve and Reject are public, so you can also theoretically both resolve and reject promises from elsewhere.

Making Promises accessible from JavaScript modules

A Promise can be wrapped in a NativePromise and fed to a NativeModule through AddMember. You can read more about creating custom js modules, and how to populate them with functions and promises, here

Location

Namespace
Uno.Threading
Package
Uno.Threading 2.9.2
Show Uno properties and methods

Interface of Promise<T>

Inherited from Future<T>

Inherited from Future

Inherited from object

Implemented Interfaces