# Is there a cross platform way of promise?

**URL:** https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613
**Category:** Silver
**Created:** [July 17, 2020, 5:05am UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613 "2020-07-17T05:05:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![contoso](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/c/5f9b8f/32.png) [@contoso](https://talk.remobjects.com/u/contoso)
#### Post date: [July 17, 2020, 5:05am UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/1 "2020-07-17T05:05:17Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 17, 2020, 11:26am UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/2 "2020-07-17T11:26:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![contoso](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/c/5f9b8f/32.png) [@contoso](https://talk.remobjects.com/u/contoso)
#### Post date: [July 17, 2020, 12:56pm UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/3 "2020-07-17T12:56:12Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 17, 2020, 9:30pm UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/4 "2020-07-17T21:30:13Z")

</div>

> [@contoso](#):
>
> 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?

---

<div class="post-metadata">

### Author: ![contoso](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/c/5f9b8f/32.png) [@contoso](https://talk.remobjects.com/u/contoso)
#### Post date: [July 18, 2020, 2:51am UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/5 "2020-07-18T02:51:30Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 18, 2020, 1:10pm UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/6 "2020-07-18T13:10:28Z")

</div>

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

```auto
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).

---

<div class="post-metadata">

### Author: ![contoso](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/c/5f9b8f/32.png) [@contoso](https://talk.remobjects.com/u/contoso)
#### Post date: [July 18, 2020, 4:10pm UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/7 "2020-07-18T16:10:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 20, 2020, 12:18pm UTC](https://talk.remobjects.com/t/is-there-a-cross-platform-way-of-promise/22613/8 "2020-07-20T12:18:41Z")

</div>

> [@contoso](#):
>
> Thank you. But I still looking for promise like approach.

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