Skip to content

Commit

Permalink
refactor(gui): Put tauri event listener registeres in dedicated function
Browse files Browse the repository at this point in the history
  • Loading branch information
binarybaron committed Aug 29, 2024
1 parent 05a6618 commit b8c8a56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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 b8c8a56

Please sign in to comment.