Skip to content

Commit 4f381be

Browse files
committed
Allow awaiting array of promises.
1 parent 9c7c58c commit 4f381be

File tree

8 files changed

+95
-7522
lines changed

8 files changed

+95
-7522
lines changed

runtime/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export { createElement, Fragment as fragment, createContext } from "preact";
22
export { useEffect, useMemo, useContext } from "preact/hooks";
33
export { signal, batch } from "@preact/signals";
44

5+
export const promiseAll = (value) => Promise.all(value);
6+
57
export * from "./src/pattern_matching";
68
export * from "./src/normalize_event";
79
export * from "./src/utilities";
@@ -15,3 +17,4 @@ export * from "./src/portals";
1517
export * from "./src/variant";
1618
export * from "./src/styles";
1719
export * from "./src/debug";
20+

spec/compilers/await_array

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
component Main {
2+
fun render : String {
3+
{
4+
await ["a", "b"]
5+
}
6+
7+
"Hello"
8+
}
9+
}
10+
--------------------------------------------------------------------------------
11+
import { promiseAll as A } from "./runtime.js";
12+
13+
export const B = () => {
14+
(async () => {
15+
return await A([
16+
`a`,
17+
`b`
18+
])
19+
})();
20+
return `Hello`
21+
};

spec/examples/await

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ component Main {
1717
""
1818
}
1919
}
20+
--------------------------------------------------------------------------------
21+
component Main {
22+
fun render : String {
23+
{
24+
let value = await [`` as Promise(String)]
25+
26+
case value {
27+
["a"] => "a"
28+
=> "b"
29+
}
30+
}
31+
32+
"Hello"
33+
}
34+
}

0 commit comments

Comments
 (0)