Skip to content

Commit

Permalink
refactor(04-zkapp-ui-with-react.mdx):move Comlink.wrap section
Browse files Browse the repository at this point in the history
  • Loading branch information
ymekuria committed Oct 1, 2024
1 parent 3b3dff3 commit cfb5519
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions docs/zkapps/tutorials/04-zkapp-ui-with-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ The web worker client code resides in the `04-zkapp-browser-ui/ui/app/zkappWorke
```
- With `Comlink.wrap`, create a proxy object `remoteApi` that provides typesafe access the worker's API methods.
```ts
// Wrap the worker with Comlink to enable direct method invocation
this.remoteApi = Comlink.wrap(this.worker);
```
- Define methods in the ZkappWorkerClient class that call the corresponding method on `remoteApi`, effectively forwarding the calls to the worker.
```ts
Expand Down Expand Up @@ -300,13 +305,6 @@ The web worker client code resides in the `04-zkapp-browser-ui/ui/app/zkappWorke
}
```
```ts
// Wrap the worker with Comlink to enable direct method invocation
this.remoteApi = Comlink.wrap(this.worker);
```
### Environment configuration
- In `04-zkapp-browser-ui/ui/app/page.tsx`
Expand Down

0 comments on commit cfb5519

Please sign in to comment.