Skip to content

Commit

Permalink
Refactor audio player event
Browse files Browse the repository at this point in the history
Remove customEventDispatcher in preparation for Svelte 5
  • Loading branch information
Mystler committed Sep 14, 2024
1 parent fc05650 commit 274ab7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/lib/components/AudioPlayer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import { GlobalAudioVolume } from "$lib/audioplayer";
import { createEventDispatcher } from "svelte";
let url: string | null = null;
let name: string;
Expand Down Expand Up @@ -52,8 +51,8 @@
}
// Provide hook for base layout
const dispatch = createEventDispatcher();
$: dispatch("urlChanged", { url });
export let onUrlChanged: (url: string | null) => void;
$: onUrlChanged(url);
</script>

{#if url}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
<div class="sticky bottom-0">
<AudioPlayer
bind:this={$GlobalAudioPlayer}
on:urlChanged={(e) => {
GlobalAudioCurrentSong.set(e.detail.url);
onUrlChanged={(url) => {
GlobalAudioCurrentSong.set(url);
}}
/>
</div>
Expand Down

0 comments on commit 274ab7b

Please sign in to comment.