Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/content/docs/workers/runtime-apis/rpc/visibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ This security model is commonly known as Object Capabilities, or Capability-Base

[Private properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties) of classes are not directly exposed over RPC.

### Arrow functions

Arrow function expressions are not exposed over RPC because they are defined on class instances, not on the class prototype. They [should not be used as class methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#cannot_be_used_as_methods) of `WorkerEntrypoint` classes.

```js
import { WorkerEntrypoint } from "cloudflare:workers";

export default class extends WorkerEntrypoint {
// add() is exposed over RPC.
add(a: number, b: number) {
return a + b;
}

// subtract() is NOT exposed over RPC.
subtract = (a: number, b: number) => a - b;
}
```

### Class instance properties

When you send an instance of an application-defined class, the recipient can only access methods and properties declared on the class, not properties of the instance. For example:
Expand Down