Skip to content

Commit a6c5411

Browse files
committed
add async example for dynamic import
1 parent 3261766 commit a6c5411

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

jscomp/test/Import.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ var each = import("../../lib/js/belt_List.js").then(function (m) {
66
return m.forEach;
77
});
88

9-
function eachInt(list, f) {
10-
var arg1 = function (each) {
11-
return Promise.resolve(Curry._2(each, list, f));
12-
};
13-
return each.then(arg1);
14-
}
15-
169
var beltAsModule = import("../../lib/js/belt_List.js");
1710

11+
async function eachInt(list, f) {
12+
var each$1 = await each;
13+
return Curry._2(each$1, list, f);
14+
}
15+
1816
exports.each = each;
19-
exports.eachInt = eachInt;
2017
exports.beltAsModule = beltAsModule;
18+
exports.eachInt = eachInt;
2119
/* No side effect */

jscomp/test/Import.res

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ let eachInt = (list: list<int>, f: int => unit) =>
66
module type BeltList = module type of Belt.List
77

88
let beltAsModule = Js.import(module(Belt.List: BeltList))
9+
10+
let eachInt = async (list: list<int>, f: int => unit) => {
11+
let each = await each
12+
list->each(f)
13+
}

0 commit comments

Comments
 (0)