Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 693x 15x 15x 15x 15x 15x 15x 15x 15x 678x 678x 678x 678x 678x 678x 678x 678x 678x 678x 693x 693x | /** @import { Readable } from './public' */
import { noop } from '../internal/shared/utils.js';
/**
* @template T
* @param {Readable<T> | null | undefined} store
* @param {(value: T) => void} run
* @param {(value: T) => void} [invalidate]
* @returns {() => void}
*/
export function subscribe_to_store(store, run, invalidate) {
if (store == null) {
// @ts-expect-error
run(undefined);
// @ts-expect-error
if (invalidate) invalidate(undefined);
return noop;
}
// Svelte store takes a private second argument
const unsub = store.subscribe(
run,
// @ts-expect-error
invalidate
);
// Also support RxJS
// @ts-expect-error TODO fix this in the types?
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
}
|