Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import AudioPlayer, { stopAll } from './AudioPlayer.svelte';
import AudioPlayer, { pauseAll } from './AudioPlayer.svelte';
import { tracks } from './tracks.js';
</script>

Expand All @@ -8,8 +8,8 @@
<AudioPlayer {...track} />
{/each}

<button onclick={stopAll}>
stop all
<button onclick={pauseAll}>
pause all
</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script module>
let current;

export function stopAll() {
export function pauseAll() {
current?.pause();
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
title: Exports
---

Anything exported from a `module` script block becomes an export from the module itself. Let's export a `stopAll` function:
Anything exported from a `module` script block becomes an export from the module itself. Let's export a `pauseAll` function:

```svelte
/// file: AudioPlayer.svelte
<script module>
let current;

+++ export function stopAll() {
+++ export function pauseAll() {
current?.pause();
}+++
</script>
```

We can now import `stopAll` in `App.svelte`...
We can now import `pauseAll` in `App.svelte`...

```svelte
/// file: App.svelte
<script>
import AudioPlayer, +++{ stopAll }+++ from './AudioPlayer.svelte';
import AudioPlayer, +++{ pauseAll }+++ from './AudioPlayer.svelte';
import { tracks } from './tracks.js';
</script>
```
Expand All @@ -34,8 +34,8 @@ We can now import `stopAll` in `App.svelte`...
<AudioPlayer {...track} />
{/each}

+++ <button onclick={stopAll}>
stop all
+++ <button onclick={pauseAll}>
pause all
</button>+++
</div>
```
Expand Down