Skip to content

Commit 7219686

Browse files
chore: update instantiation of async context to use variable (#131)
1 parent b95fd7c commit 7219686

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

USE-CASES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ sync and async execution by keeping track of the context in which we started the
127127
execution.
128128

129129
```typescript
130-
const context = new AsyncContext();
130+
const context = new AsyncContext.Variable();
131131

132132
export function log() {
133133
const currentId = context.get();
@@ -158,7 +158,7 @@ doc.addEventListener('click', () => {
158158
});
159159
});
160160
// Some framework code
161-
const context = new AsyncContext();
161+
const context = new AsyncContext.Variable();
162162
function patch(doc, data) {
163163
doLotsOfWork(doc, data, update);
164164
}
@@ -237,7 +237,7 @@ doc.addEventListener('click', () => {
237237
});
238238
});
239239

240-
const context = new AsyncContext();
240+
const context = new AsyncContext.Variable();
241241
function patch(dom, data) {
242242
doLotsOfWork(dom, data, update);
243243
}
@@ -343,7 +343,7 @@ Read more at [opentelemetry/fetch](https://github.com/open-telemetry/opentelemet
343343

344344
## Use Case: Running servers in service workers
345345

346-
A typical web app has a server-side component and a client-side component. Many web frameworks (Next, Nuxt, SvelteKit etc) are designed in such a way that both halves can be built from a single codebase.
346+
A typical web app has a server-side component and a client-side component. Many web frameworks (Next, Nuxt, SvelteKit etc) are designed in such a way that both halves can be built from a single codebase.
347347

348348
One request that framework maintainers often receive is for the ability to run the server, or at least part of it, in a service worker. Barring any dependencies on sensitive information that should not be accessible to users, or packages that only run in a server environment, this can be a successful strategy for building low-latency apps that are resilient in the face of poor network conditions.
349349

0 commit comments

Comments
 (0)