Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export MemberSelectors type from @watchable/store #90

Open
cefn opened this issue Oct 6, 2024 · 0 comments
Open

Export MemberSelectors type from @watchable/store #90

cefn opened this issue Oct 6, 2024 · 0 comments
Labels
store Related to @watchable/store

Comments

@cefn
Copy link
Owner

cefn commented Oct 6, 2024

I've found this to be a useful utility for creating reference selectors which simply select members, but can have a long-lived permanently memoized version. As it's type-only it doesn't have any overhead to add it to the bundle.

/** SELECTORS */

type MemberSelectors<T extends RootState> = {
  [k in keyof T]?: (state: T) => T[k];
};

/** Memoized selectors for named members */
export const SELECTORS = {
  searchPostings: (state) => state.searchPostings,
  searchTerms: (state) => state.searchTerms,
  focusSavedMs: (state) => state.focusSavedMs,
} as const satisfies MemberSelectors<CacheState>;
@cefn cefn added the store Related to @watchable/store label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
store Related to @watchable/store
Projects
None yet
Development

No branches or pull requests

1 participant