Skip to content

Commit 25b0864

Browse files
committed
docs: remove reference to Js.Promise
1 parent 3a050b2 commit 25b0864

File tree

1 file changed

+2
-68
lines changed

1 file changed

+2
-68
lines changed

markdown-pages/docs/manual/promise.mdx

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ order: 21
1414

1515
**Since 10.1**
1616

17-
In ReScript, every JS promise is represented with the globally available `promise<'a>` type. For ReScript versions < 10.1, use its original alias `Js.Promise.t<'a>` instead.
17+
In ReScript, every JS promise is represented with the globally available `promise<'a>` type.
1818

1919
Here's a usage example in a function signature:
2020

@@ -112,70 +112,4 @@ async function logAsyncMessage(param) {
112112
export { logAsyncMessage };
113113
```
114114

115-
</CodeTab>
116-
117-
## Js.Promise module (legacy - do not use)
118-
119-
> **Note:** The `Js.Promise` bindings are following the outdated data-last convention from a few years ago. We kept those APIs for backwards compatibility. Either use [`Promise`](/docs/manual/api/stdlib/promise) or a third-party promise binding instead.
120-
121-
ReScript has built-in support for [JavaScript promises](/docs/manual/api/stdlib/promise). The 3 functions you generally need are:
122-
123-
- `Js.Promise.resolve: 'a => Js.Promise.t<'a>`
124-
- `Js.Promise.then_: ('a => Js.Promise.t<'b>, Js.Promise.t<'a>) => Js.Promise.t<'b>`
125-
- `Js.Promise.catch: (Js.Promise.error => Js.Promise.t<'a>, Js.Promise.t<'a>) => Js.Promise.t<'a>`
126-
127-
Additionally, here's the type signature for creating a promise on the ReScript side:
128-
129-
```res
130-
Js.Promise.make: (
131-
(
132-
~resolve: (. 'a) => unit,
133-
~reject: (. exn) => unit
134-
) => unit
135-
) => Js.Promise.t<'a>
136-
```
137-
138-
This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](./function.mdx#uncurried-function) (with a dot). `make` returns the created promise.
139-
140-
### Usage
141-
142-
Using the [pipe operator](./pipe.mdx):
143-
144-
<CodeTab labels={["ReScript", "JS Output"]}>
145-
146-
```res example
147-
let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2))
148-
149-
myPromise->Js.Promise.then_(value => {
150-
Console.log(value)
151-
Js.Promise.resolve(value + 2)
152-
}, _)->Js.Promise.then_(value => {
153-
Console.log(value)
154-
Js.Promise.resolve(value + 3)
155-
}, _)->Js.Promise.catch(err => {
156-
Console.log2("Failure!!", err)
157-
Js.Promise.resolve(-2)
158-
}, _)
159-
```
160-
161-
```js
162-
var myPromise = new Promise(function (resolve, reject) {
163-
return resolve(2);
164-
});
165-
166-
myPromise
167-
.then(function (value) {
168-
console.log(value);
169-
return Promise.resolve((value + 2) | 0);
170-
})
171-
.then(function (value) {
172-
console.log(value);
173-
return Promise.resolve((value + 3) | 0);
174-
})
175-
.catch(function (err) {
176-
console.log("Failure!!", err);
177-
return Promise.resolve(-2);
178-
});
179-
```
180-
181-
</CodeTab>
115+
</CodeTab>

0 commit comments

Comments
 (0)