-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve web worker interface #1045
base: main
Are you sure you want to change the base?
Conversation
… in the UI package
…ation with web workers for improved performance and concurrency
…mmunication to clean up the file and improve readability
…orker's methods as if they were local
…mlink in constructor
…pi for better code organization and readability
…pdateTransaction method to use remoteApi with web worker
…emoteApi with web worker
…ove functionality and state management in Home component
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
…ly convert publicKey to base58 before fetching account data
… functions by directly passing PublicKey object instead of an object with publicKey58 property
…blicKey directly without converting it to base58, as it is already in the correct format
… set up initial state, handle account existence checks, create and send transactions, refresh current state, and create UI elements for the Home page.
…e rendering to optimize bundle size and improve performance
…g of gradient background pixels for better performance
…ic gradient background using canvas and react
… data using zkappWorkerClient
…le zkApp compilation and initialization
…r consistency and clarity
…to clean up code and improve readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, this is a great UX improvement! I think we should amend the actual tutorial too to include a better explanation of what Comlink does and how we use it
type Transaction = Awaited<ReturnType<typeof Mina.transaction>>; | ||
|
||
const state = { | ||
Add: null as null | typeof Add, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe calling this AddContract
and renaming zkapp
to contractInstance
makes this a bit clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea.
I will update the actual tutorial in a follow up PR. |
… 'o1js' library and return API object to ensure worker api is availble after import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I am missing context about what it was like before. I can approve, but probably someone else should give you their opinion.
…ion link to clean up code and improve readability
Summary
This PR improves the implementation of integrating web workers in a UI with
o1js
. The comlink package was introduced to simplify the communication with web workers by abstracting message passing, and making them appear like regular asynchronous functions without the complexity of managing postMessage.Impact
Currently web workers are necessary to build performant and usable UIs with
o1js
. Integrating and managing web workers witho1js
is complex, and hard to manage according to many developers on discord. These developers have requested that we simplify the process. Integrating comlink simplifies the DX and allows more developers to build performant UIs with less complexity.Changes
zkappWorker.ts
andzkappWorkerClient.ts
were simplifiedNextJS
page router
to theapp router
Future Plans
The long term goal is to eliminate the need for web workers with updates to
o1js
. In the short term we are aiming to improve the DX of building UIs with changes like this one. This example implementation will be incrementally improved until we reach the longer term goal with improvements too1js
.