implement onSelectionChanged

This commit is contained in:
peterkogo
2025-04-30 20:32:06 +02:00
parent adb13e261d
commit 47f9118296
13 changed files with 108 additions and 11 deletions
@@ -0,0 +1,15 @@
import type { OnSelectionChanged } from '$lib/types';
import { useStore } from '$lib/hooks/useStore';
export function useSelectionChanged(onselectionchanged: OnSelectionChanged) {
const store = $derived(useStore());
const symbol = Symbol();
$effect(() => {
store.selectionChangedHandlers.set(symbol, onselectionchanged);
return () => {
store.selectionChangedHandlers.delete(symbol);
};
});
}