A music player that connects to your cloud/distributed storage.
at v4 30 lines 612 B view raw
1import { effect } from "~/common/signal.js"; 2 3/** 4 * @import {SignalReader} from "~/common/signal.d.ts"; 5 */ 6 7/** 8 * @template T 9 * @param {{ collection: SignalReader<{ state: "loading" } | { state: "loaded"; data: T }> }} output 10 * @returns {Promise<T>} 11 */ 12export async function data(output) { 13 return await new Promise((resolve) => { 14 let resolved = false; 15 16 const stop = effect(() => { 17 if (resolved) { 18 stop(); 19 return; 20 } 21 22 const col = output.collection(); 23 24 if (col.state === "loaded") { 25 resolved = true; 26 resolve(col.data); 27 } 28 }); 29 }); 30}