You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
10
10
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.
12
12
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.
14
36
15
37
ReScript has built-in support for [JavaScript promises](api/js/promise). The 3 functions you generally need are:
16
38
@@ -32,7 +54,7 @@ Js.Promise.make: (
32
54
This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](
33
55
function.md#uncurried-function) (with a dot). `make` returns the created promise.
0 commit comments