From efda2fd07e5714a95c38c40a972629bcb749ce06 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Tue, 11 Nov 2025 11:42:01 +0000 Subject: [PATCH] Add an async/await example in the solution --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ee912dc..a6d83a5 100644 --- a/README.md +++ b/README.md @@ -201,8 +201,12 @@ const asyncVar = new AsyncContext.Variable(); // Sets the current value to 'top', and executes the `main` function. asyncVar.run("top", main); -function main() { - // AsyncContext.Variable is maintained through other platform queueing. +async function main() { + // AsyncContext.Variable is propagated on async/await. + await Promise.resolve(); + console.log(asyncVar.get()); // => 'top' + + // AsyncContext.Variable is propagated through platform tasks. setTimeout(() => { console.log(asyncVar.get()); // => 'top'