import { useSyncExternalStore } from 'react';
import { LLStore } from '../store';

export function useSelectedFieldStore<
  Store extends LLStore<unknown>,
  SelectedValue
>(store: Store, selectorFn?: () => SelectedValue): SelectedValue {
  return useSyncExternalStore(store.subscribe, selectorFn);
}
