Skip to content

Commit 1bb0516

Browse files
committed
Update promise docs
1 parent 3f5832d commit 1bb0516

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

pages/docs/manual/latest/promise.mdx

+25-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,31 @@ canonical: "/docs/manual/latest/promise"
88

99
ReScript's primary mechanism for async programming is the same as JavaScript's (callbacks and promises), since we compile cleanly to JavaScript and would like to avoid dragging in a heavy custom runtime.
1010

11-
However, it is planned for us to introduce a coroutine-like feature in the future; for that reason, we're postponing introducing the keywords `async` and `await` into the language; though our (upcoming) Promise API bindings revamp + [pipe](pipe) will make your async code already look better than otherwise.
11+
There is currently no support for `async` and `await` keywords in ReScript; though our new Promise API bindings revamp + [pipe](pipe) will make your async code already look better than otherwise.
1212

13-
## Promise
13+
## Promise (new)
14+
15+
Our up to date Promise bindings are currently not part of the the standard library. For now, please install them separately:
16+
17+
```sh
18+
npm install @ryyppy/rescript-promise --save
19+
```
20+
21+
In your `bsconfig.json`:
22+
23+
```json
24+
{
25+
"bs-dependencies": ["@ryyppy/rescript-promise"]
26+
}
27+
```
28+
29+
_Alternatively you may vendor the [`Promise.res` / `Promise.resi` files](https://github.com/ryyppy/rescript-promise/tree/master/src) files in your app codebase if you want to have more control._
30+
31+
You can find the APIs and full usage examples [here](https://github.com/ryyppy/rescript-promise#usage).
32+
33+
## Promise (legacy)
34+
35+
> **Note:** The `Js.Promise` bindings are following the outdated data-last convention from a few years ago. We kept those APIs for backwards compatibility, so for now please use [`rescript-promise`](https://github.com/ryyppy/rescript-promise) until we upstream the new bindings to our standard library.
1436
1537
ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are:
1638

@@ -32,7 +54,7 @@ Js.Promise.make: (
3254
This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](
3355
function.md#uncurried-function) (with a dot). `make` returns the created promise.
3456

35-
## Usage
57+
### Usage
3658

3759
Using the [pipe operator](pipe.md):
3860

@@ -73,5 +95,3 @@ myPromise
7395
```
7496

7597
</CodeTab>
76-
77-

0 commit comments

Comments
 (0)