mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 22:26:01 +00:00
19 lines
439 B
TypeScript
19 lines
439 B
TypeScript
import { writable } from 'svelte/store';
|
|
|
|
export default function memberStore(store, extractStore) {
|
|
let res;
|
|
let unsubscribeSub = null;
|
|
store.subscribe(value => {
|
|
const subStore = extractStore(value);
|
|
if (unsubscribeSub) unsubscribeSub();
|
|
unsubscribeSub = subStore.subscribe(subValue => {
|
|
if (res) {
|
|
res.set(subValue);
|
|
} else {
|
|
res = writable(subValue);
|
|
}
|
|
});
|
|
});
|
|
return res;
|
|
}
|