Skip to content

Commit 8c752c1

Browse files
committed
tweak example
1 parent 976658e commit 8c752c1

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

example-async/src/AA.mjs

+17-16
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,23 @@ async function ff(url) {
184184
}
185185

186186
async function testFetchMany() {
187-
return Belt_List.forEach(await map({
188-
hd: "https://www.google.com",
189-
tl: {
190-
hd: "https://www.google.com",
191-
tl: {
192-
hd: "https://www.google.com",
193-
tl: {
194-
hd: "https://www.google.com",
195-
tl: {
196-
hd: "https://www.google.com",
197-
tl: /* [] */0
198-
}
199-
}
200-
}
201-
}
202-
}, ff), (function (param) {
187+
var fetchedItems = await map({
188+
hd: "https://www.google.com",
189+
tl: {
190+
hd: "https://www.google.com",
191+
tl: {
192+
hd: "https://www.google.com",
193+
tl: {
194+
hd: "https://www.google.com",
195+
tl: {
196+
hd: "https://www.google.com",
197+
tl: /* [] */0
198+
}
199+
}
200+
}
201+
}
202+
}, ff);
203+
return Belt_List.forEach(fetchedItems, (function (param) {
203204
console.log("Fetched", param[0], param[1]);
204205
}));
205206
}

example-async/src/AA.res

+17-16
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ let nestedPromise =
7575
// Test error handling in fetch
7676

7777
module Fetch = {
78-
@raises(JsError)
78+
//@raises(JsError)
7979
let fetch = url => Fetch.fetch(url)
8080

81-
@raises([])
8281
let status = response => Fetch.Response.status(response)
8382
}
8483

@@ -149,19 +148,21 @@ let fetchAndCount = {
149148

150149
let testFetchMany =
151150
@async
152-
(. ()) =>
153-
@await
154-
AsyncList.map(.
155-
list{
156-
"https://www.google.com",
157-
"https://www.google.com",
158-
"https://www.google.com",
159-
"https://www.google.com",
160-
"https://www.google.com",
161-
},
162-
fetchAndCount,
163-
)->Belt.List.forEach(((i, s)) => Js.log3("Fetched", i, s))
164-
151+
(. ()) => {
152+
let fetchedItems =
153+
@await
154+
AsyncList.map(.
155+
list{
156+
"https://www.google.com",
157+
"https://www.google.com",
158+
"https://www.google.com",
159+
"https://www.google.com",
160+
"https://www.google.com",
161+
},
162+
fetchAndCount,
163+
)
164+
fetchedItems->Belt.List.forEach(((i, s)) => Js.log3("Fetched", i, s))
165+
}
165166
testFetchMany->addTest
166167

167168
//
@@ -219,7 +220,7 @@ let rec runAllTests =
219220
(. n) => {
220221
if n >= 0 && n < Array.length(tests) {
221222
@await
222-
tests[n](.)
223+
(@doesNotRaise tests[n])(.)
223224

224225
@await
225226
runAllTests(. n + 1)

0 commit comments

Comments
 (0)