implement onSelectionChanged
This commit is contained in:
@@ -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);
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user