Skip to content

Commit 12cc2e7

Browse files
authored
this.ctx instead of this.state (#25145)
1 parent 944ae50 commit 12cc2e7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/content/docs/durable-objects/examples/alarms-api.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ const SECONDS = 10;
2929

3030
// Durable Object
3131
export class Batcher extends DurableObject {
32-
constructor(state, env) {
33-
super(state, env);
34-
this.storage = state.storage;
35-
this.state.blockConcurrencyWhile(async () => {
32+
constructor(ctx, env) {
33+
super(ctx, env);
34+
this.storage = ctx.storage;
35+
this.ctx.blockConcurrencyWhile(async () => {
3636
let vals = await this.storage.list({ reverse: true, limit: 1 });
3737
this.count = vals.size == 0 ? 0 : parseInt(vals.keys().next().value);
3838
});

src/content/docs/durable-objects/reference/in-memory-state.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ A common pattern is to initialize a Durable Object from [persistent storage](/du
1515

1616
```js
1717
export class Counter {
18-
constructor(state, env) {
19-
this.state = state;
18+
constructor(ctx, env) {
19+
this.ctx = ctx;
2020
// `blockConcurrencyWhile()` ensures no requests are delivered until
2121
// initialization completes.
22-
this.state.blockConcurrencyWhile(async () => {
23-
let stored = await this.state.storage.get("value");
22+
this.ctx.blockConcurrencyWhile(async () => {
23+
let stored = await this.ctx.storage.get("value");
2424
// After initialization, future reads do not need to access storage.
2525
this.value = stored || 0;
2626
});

src/content/docs/kv/concepts/kv-bindings.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ An example might look like:
8484

8585
```js
8686
export class DurableObject {
87-
constructor(state, env) {
88-
this.state = state;
87+
constructor(ctx, env) {
88+
this.ctx = ctx;
8989
this.env = env;
9090
}
9191

0 commit comments

Comments
 (0)