Skip to content

Commit 5a9944d

Browse files
committed
Revert "Adding fetch and alarm. Actioning PR comments."
This reverts commit 6088c07.
1 parent 6088c07 commit 5a9944d

File tree

4 files changed

+36
-61
lines changed

4 files changed

+36
-61
lines changed

package-lock.json

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/docs/durable-objects/api/base.mdx

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,12 @@ sidebar:
55
order: 1
66
---
77

8-
import { Render, Tabs, TabItem, GlossaryTooltip, Type, MetaInfo, TypeScriptExample } from "~/components";
8+
import { Render, Tabs, TabItem, GlossaryTooltip, Type, MetaInfo } from "~/components";
99

10-
The `DurableObject` base class is an abstract class which all Durable Objects inherit from. This base class provides a set of optional methods, frequently referred to as handler methods, which can respond to events, for example a webSocketMessage when using the [WebSocket Hibernation API](#/durable-objects/best-practices/websockets/#websocket-hibernation-api). To provide a concrete example, here is a Durable Object `MyDurableObject` which extends `DurableObject` and implements the fetch handler to return "Hello, World!" to the calling Worker.
11-
12-
<TypeScriptExample>
13-
```ts
14-
export class MyDurableObject extends DurableObject {
15-
constructor(ctx: DurableObjectState, env: Env) {
16-
super(ctx, env);
17-
}
18-
19-
async fetch(request: Request) {
20-
return new Response("Hello, World!");
21-
}
22-
}
23-
```
24-
</TypeScriptExample>
10+
{/* DEFINITION OF DO BASE CLASS TBC */}
2511

2612
## Methods
2713

28-
### `fetch`
29-
30-
- <code>fetch(<Type text="Request"/>)</code>: <Type text="Response"/> | <Type text="Promise <Response>"/>
31-
32-
- Takes an HTTP request object and returns an HTTP response object. This method allows the Durable Object to emulate an HTTP server where a Worker with a binding to that object is the client.
33-
34-
- This method can be `async`.
35-
36-
### `alarm`
37-
38-
- <code>alarm()</code>: <Type text="Promise <void>"/>
39-
40-
- See [Alarms](/durable-objects/api/alarms/).
41-
4214
### `webSocketMessage`
4315

4416
- <code> webSocketMessage(ws <Type text="WebSocket" />, message{" "} <Type text="string | ArrayBuffer" />)</code>: <Type text="void" />
@@ -67,13 +39,7 @@ export class MyDurableObject extends DurableObject {
6739

6840
## Properties
6941

70-
### `DurableObjectState`
71-
72-
See [`DurableObjectState` documentation](/durable-objects/api/state/).
73-
74-
### `Env`
75-
76-
A list of bindings which are available to the Durable Object.
42+
{/* Properties of DO Base Class TBC */}
7743

7844
## Related resources
7945

src/content/docs/durable-objects/api/state.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ export class MyDurableObject extends DurableObject {
267267

268268
- None.
269269

270+
## Extended methods
271+
272+
### `serializeAttachment`
273+
274+
- <code> serializeAttachment(value <Type text="any" />)</code>: <Type text="void" />
275+
276+
- Keeps a copy of `value` in memory (not on disk) to survive hibernation. The value can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), which is true of most types.
277+
278+
- If you modify `value` after calling this method, those changes will not be retained unless you call this method again. The serialized size of `value` is limited to 2,048 bytes, otherwise this method will throw an error. If you need larger values to survive hibernation, use the [Storage API](/durable-objects/api/storage-api/) and pass the corresponding key to this method so it can be retrieved later.
279+
280+
### `deserializeAttachment`
281+
282+
- `deserializeAttachment()`: <Type text='any' />
283+
284+
- Retrieves the most recent value passed to `serializeAttachment()`, or `null` if none exists.
285+
270286
## Properties
271287

272288
### `id`

src/content/docs/durable-objects/best-practices/websockets.mdx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -379,22 +379,6 @@ If you are using older versions, note that while hibernatable WebSocket events s
379379

380380
:::
381381

382-
## Extended methods
383-
384-
### `serializeAttachment`
385-
386-
- <code> serializeAttachment(value <Type text="any" />)</code>: <Type text="void" />
387-
388-
- Keeps a copy of `value` in memory (not on disk) to survive hibernation. The value can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), which is true of most types.
389-
390-
- If you modify `value` after calling this method, those changes will not be retained unless you call this method again. The serialized size of `value` is limited to 2,048 bytes, otherwise this method will throw an error. If you need larger values to survive hibernation, use the [Storage API](/durable-objects/api/storage-api/) and pass the corresponding key to this method so it can be retrieved later.
391-
392-
### `deserializeAttachment`
393-
394-
- `deserializeAttachment()`: <Type text='any' />
395-
396-
- Retrieves the most recent value passed to `serializeAttachment()`, or `null` if none exists.
397-
398382
## Related resources
399383

400384
- [Mozilla Developer Network's (MDN) documentation on the WebSocket class](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)

0 commit comments

Comments
 (0)