Is there a cross platform way of promise?

When I examine RTL2, it consist a lot of callback function.
for example, a http request.

In that case I want return a future type or similar promise type which is cross platform ready like RTL2.

Is there such class?

in Oxygene, you can use future types: https://docs.elementscompiler.com/Oxygene/Types/FutureTypes/

@mh can Oxygene future types pass a future types to wait RTL2 http’s callbacks?
If I can pass the future types then I want to await it from the outside function.

can you elaborate?

I would like to do it something like this.
here is my pseudo code
Future fetchData(url) async {
final fut = Completer();
rtl2.http.fetch(url, (resp) => fut.complete(resp.body.toString())
return fut.future;
}

with completer, I can simply wrap callback function and pass future type as a return value of a function. which maybe awaited from other function.

you could so something like (again, futures are only in Oxygene, right now) something like this

var xml := async Http.ExecuteRequestSynchronous(new HttpRequest(Url.UrlWithString("https://www.example.com/xml"))).TryGetContentAsXmlSynchronous;

and xml would be a “future XmlDocument”. it gets download din the background, and the first time you then touch the variable to do anything with ti, it woudl join back up, or wait (if not done yet).

Thank you. But I still looking for promise like approach.
That way, we can wrap async functions while we don’t have to use synchronous functions.
In my example earlier, I could use closure for the callback function and pass the actual callback argument into the completer.

I would n to know about that, then. future types, and async/await are the two mechanisms we support.