Skip to content

Commit 5313421

Browse files
committed
2 parents f7840a0 + 5f43e9d commit 5313421

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
let
2+
/*
3+
See more:
4+
- [Dynamic, Lazy Records](https://bengribaudo.com/blog/2021/08/09/5941/dynamic-lazy-records)
5+
6+
*/
7+
// example showing that Api1() isn't always called
8+
// if they are called, it will delay for 3 seconds to simulate a query or web request
9+
// skip load ends up skipping the query, and the 3 second delay
10+
delay = #duration(0,0,0, 3),
11+
SkipLoad = true,
12+
13+
// sleep for delay Seconds and return a string
14+
Api1 = () => Function.InvokeAfter(
15+
() => "Api1 finished", delay ),
16+
17+
// for fun, this version uses a string template to create the error rmessage
18+
Api2 =() => Function.InvokeAfter(
19+
() =>
20+
Text.Format(
21+
"Api2 finished, at #[dt]",
22+
[ dt = DateTime.LocalNow() ]
23+
),
24+
delay ),
25+
26+
// the important part of the query:
27+
ApiList = { Api1(), Api2() },
28+
Query2 = { "some", "Fallback" },
29+
Final = if SkipLoad = true then Query2 else ApiList
30+
in
31+
Final

0 commit comments

Comments
 (0)