From e3dd7914e97d2afcbf95c354a5a9d7e3d51bdd4d Mon Sep 17 00:00:00 2001 From: ymekuria Date: Thu, 13 Jul 2023 12:53:19 -0700 Subject: [PATCH] feat: initialize worker client before post message --- .../04-zkapp-browser-ui/ui/src/pages/_app.page.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/_app.page.tsx b/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/_app.page.tsx index 1320df5f0..8c8f93562 100644 --- a/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/_app.page.tsx +++ b/examples/zkapps/04-zkapp-browser-ui/ui/src/pages/_app.page.tsx @@ -24,9 +24,18 @@ export default function App() { // Do Setup useEffect(() => { + async function timeout(seconds: number): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, seconds * 1000); + }); + } + (async () => { if (!state.hasBeenSetup) { const zkappWorkerClient = new ZkappWorkerClient(); + await timeout(5); console.log('Loading SnarkyJS...'); await zkappWorkerClient.loadSnarkyJS();