Moving audio message to Svelte
This commit is contained in:
parent
faa4c7c08e
commit
267d0a2cd1
11 changed files with 110 additions and 74 deletions
22
front/src/Stores/SoundPlayingStore.ts
Normal file
22
front/src/Stores/SoundPlayingStore.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { writable } from "svelte/store";
|
||||
|
||||
/**
|
||||
* A store that contains the URL of the sound currently playing
|
||||
*/
|
||||
function createSoundPlayingStore() {
|
||||
const { subscribe, set, update } = writable<string|null>(null);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
playSound: (url: string) => {
|
||||
set(url);
|
||||
},
|
||||
soundEnded: () => {
|
||||
set(null);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
export const soundPlayingStore = createSoundPlayingStore();
|
Loading…
Add table
Add a link
Reference in a new issue