-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (26 loc) · 1.05 KB
/
app.js
File metadata and controls
31 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
console.log("******** enter the init block ********");
let resolved = "No";
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms)).then(() => {resolved = "Yes!"});
}
/**
* This is the portion of the lifecycle hook that is
* implemented by customers. In this case we are creating
* a blocking call to a sleep method for 5 seconds.
*
* If you run this example in your terminal you can see the
* that await is honored, the function blocks, and then
* wakes up prior to invocation.
*/
exports.initializeFunction = async () => {
console.log("******** enter initializeFunction hook ********");
console.log("******** Is promised resolved? " + resolved + " ********");
console.log("******** sleep for 5 seconds... ********")
let p = await sleep(5000);
console.log("******** wake up ********");
}
exports.handler = async (event, context) => {
console.log("******** enter the handler ********");
console.log("******** Is promised resolved? " + resolved + " ********");
return 'Function complete.';
}