Skip to content

Commit 72aa5ce

Browse files
committed
example
1 parent 824d91a commit 72aa5ce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,16 @@ Allows injecting values from a parent scope into child scopes in async context.
55
```
66
npm i async-context
77
```
8+
9+
## example
10+
11+
```ts
12+
const { inject, access } = context((): string => "nothing injected");
13+
const withString = inject(() => "injected");
14+
15+
const f = () => Promise.resolve(access());
16+
17+
await withString(f)(); // "injected"
18+
19+
await f(); // "nothing injected"
20+
```

0 commit comments

Comments
 (0)