Skip to content

Commit

Permalink
Merge pull request #53 from UnstoppableSwap/gui/tauri-event-listener-…
Browse files Browse the repository at this point in the history
…init-fn

refactor(gui): Put tauri event listener registeres in dedicated function
  • Loading branch information
binarybaron authored Aug 29, 2024
2 parents d913206 + b8c8a56 commit 1b1fe0a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src-gui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
.vite
*.local

# Editor directories and files
Expand Down
3 changes: 2 additions & 1 deletion src-gui/src/renderer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { persistor, store } from "./store/storeRenderer";
setInterval(() => {
checkBitcoinBalance();
getRawSwapInfos();
}, 5000);
}, 30 * 1000);

const container = document.getElementById("root");
const root = createRoot(container!);
Expand Down Expand Up @@ -65,3 +65,4 @@ async function fetchInitialData() {
}

fetchInitialData();
initEventListeners();
10 changes: 6 additions & 4 deletions src-gui/src/renderer/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ import { store } from "./store/storeRenderer";
import { Provider } from "models/apiModel";
import { providerToConcatenatedMultiAddr } from "utils/multiAddrUtils";

listen<TauriSwapProgressEventWrapper>("swap-progress-update", (event) => {
console.log("Received swap progress event", event.payload);
store.dispatch(swapTauriEventReceived(event.payload));
});
export async function initEventListeners() {
listen<TauriSwapProgressEventWrapper>("swap-progress-update", (event) => {
console.log("Received swap progress event", event.payload);
store.dispatch(swapTauriEventReceived(event.payload));
});
}

async function invoke<ARGS, RESPONSE>(
command: string,
Expand Down

0 comments on commit 1b1fe0a

Please sign in to comment.