File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,10 @@ const SECONDS = 10;
2929
3030// Durable Object
3131export 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 });
Original file line number Diff line number Diff line change @@ -15,12 +15,12 @@ A common pattern is to initialize a Durable Object from [persistent storage](/du
1515
1616``` js
1717export 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 });
Original file line number Diff line number Diff line change @@ -84,8 +84,8 @@ An example might look like:
8484
8585``` js
8686export class DurableObject {
87- constructor (state , env ) {
88- this .state = state ;
87+ constructor (ctx , env ) {
88+ this .ctx = ctx ;
8989 this .env = env;
9090 }
9191
You can’t perform that action at this time.
0 commit comments