Skip to content

Export MemberSelectors type from @watchable/store #90

Description

@cefn

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>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    storeRelated to @watchable/store

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions