21 lines
634 B
JavaScript
21 lines
634 B
JavaScript
import { ar as noop, d as untrack } from "./runtime-DInTlc-h.js";
|
|
// node_modules/svelte/src/store/utils.js
|
|
/** @import { Readable } from './public' */
|
|
/**
|
|
* @template T
|
|
* @param {Readable<T> | null | undefined} store
|
|
* @param {(value: T) => void} run
|
|
* @param {(value: T) => void} [invalidate]
|
|
* @returns {() => void}
|
|
*/
|
|
function subscribe_to_store(store, run, invalidate) {
|
|
if (store == null) {
|
|
run(void 0);
|
|
if (invalidate) invalidate(void 0);
|
|
return noop;
|
|
}
|
|
const unsub = untrack(() => store.subscribe(run, invalidate));
|
|
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
|
}
|
|
export { subscribe_to_store as t };
|