mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-22 13:48:13 +03:00
fix(example): unlisten to event on tab change in api example (#1436)
* unlisten to event on tab change in api example * rewrite Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
parent
f4ae2d2487
commit
9ce0569f17
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,10 +1,19 @@
|
||||
<script>
|
||||
import { listen, emit } from "@tauri-apps/api/event";
|
||||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { onMount, onDestroy } from "svelte";
|
||||
|
||||
export let onMessage;
|
||||
let unlisten;
|
||||
|
||||
listen("rust-event", onMessage)
|
||||
onMount(async () => {
|
||||
unlisten = await listen("rust-event", onMessage)
|
||||
})
|
||||
onDestroy(() => {
|
||||
if (unlisten) {
|
||||
unlisten()
|
||||
}
|
||||
})
|
||||
|
||||
function log() {
|
||||
invoke("log_operation", {
|
||||
|
Loading…
Reference in New Issue
Block a user