partey_workadventure/front/src/Stores/SoundPlayingStore.ts

21 lines
457 B
TypeScript
Raw Normal View History

2021-06-02 16:46:28 +02:00
import { writable } from "svelte/store";
/**
* A store that contains the URL of the sound currently playing
*/
function createSoundPlayingStore() {
2021-09-06 14:27:54 +02:00
const { subscribe, set, update } = writable<string | null>(null);
2021-06-02 16:46:28 +02:00
return {
subscribe,
playSound: (url: string) => {
set(url);
},
soundEnded: () => {
set(null);
2021-09-06 14:27:54 +02:00
},
2021-06-02 16:46:28 +02:00
};
}
export const soundPlayingStore = createSoundPlayingStore();