Skip to content

Commit

Permalink
tweak example
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoc committed May 31, 2022
1 parent 976658e commit 8c752c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
33 changes: 17 additions & 16 deletions example-async/src/AA.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,23 @@ async function ff(url) {
}

async function testFetchMany() {
return Belt_List.forEach(await map({
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: /* [] */0
}
}
}
}
}, ff), (function (param) {
var fetchedItems = await map({
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: {
hd: "https://www.google.com",
tl: /* [] */0
}
}
}
}
}, ff);
return Belt_List.forEach(fetchedItems, (function (param) {
console.log("Fetched", param[0], param[1]);
}));
}
Expand Down
33 changes: 17 additions & 16 deletions example-async/src/AA.res
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ let nestedPromise =
// Test error handling in fetch

module Fetch = {
@raises(JsError)
//@raises(JsError)
let fetch = url => Fetch.fetch(url)

@raises([])
let status = response => Fetch.Response.status(response)
}

Expand Down Expand Up @@ -149,19 +148,21 @@ let fetchAndCount = {

let testFetchMany =
@async
(. ()) =>
@await
AsyncList.map(.
list{
"https://www.google.com",
"https://www.google.com",
"https://www.google.com",
"https://www.google.com",
"https://www.google.com",
},
fetchAndCount,
)->Belt.List.forEach(((i, s)) => Js.log3("Fetched", i, s))

(. ()) => {
let fetchedItems =
@await
AsyncList.map(.
list{
"https://www.google.com",
"https://www.google.com",
"https://www.google.com",
"https://www.google.com",
"https://www.google.com",
},
fetchAndCount,
)
fetchedItems->Belt.List.forEach(((i, s)) => Js.log3("Fetched", i, s))
}
testFetchMany->addTest

//
Expand Down Expand Up @@ -219,7 +220,7 @@ let rec runAllTests =
(. n) => {
if n >= 0 && n < Array.length(tests) {
@await
tests[n](.)
(@doesNotRaise tests[n])(.)

@await
runAllTests(. n + 1)
Expand Down

0 comments on commit 8c752c1

Please sign in to comment.