Skip to content

Commit

Permalink
comments updated
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Dec 12, 2024
1 parent 2804335 commit 94f4238
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/store/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { useConfigStore } from './stores/config';
import { useUIStore } from './stores/ui';
import { useSearchStore } from './stores/search';

// "createSelectors" can be used here for generation of the memoized selectors.
// Now this function is non-optimized and its usage causes memory leaks.
// The "createSelectors" function can be utilized here to generate memoized selectors
// Note: "createSelectors" is currently unoptimized and may result in memory leaks if used as is
export const useStatusState = useStatusStore;
export const useLoadingState = useLoadingStateStore;
export const useMarcPreviewState = useMarcPreviewStore;
Expand Down
4 changes: 2 additions & 2 deletions src/store/utils/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ type WithSelectors<S> = S extends {
? S & { use: { [K in keyof T]: T[K] } }
: never;

// Use this function to generate all available selectors.
// Now it causes memory leaks if invoke it after each re-render, so it should be memoized.
// Use this function to generate all available selectors
// Currently, invoking it after each re-render leads to memory leaks, so it should be memoized to prevent this issue
export const createSelectors = <S extends UseBoundStore<StoreApi<object>>>(_store: S) => {
const store = _store as WithSelectors<typeof _store>;
store.use = {};
Expand Down

0 comments on commit 94f4238

Please sign in to comment.