diff --git a/packages/ngrx-rtk-query/core/src/module.ts b/packages/ngrx-rtk-query/core/src/module.ts index 8ebd2f0..f0fe31f 100644 --- a/packages/ngrx-rtk-query/core/src/module.ts +++ b/packages/ngrx-rtk-query/core/src/module.ts @@ -29,6 +29,8 @@ export type Dispatch = ( action: Action | ThunkAction, ) => ReturnType extends Action ? Action : ReturnType; +export type UseSelector = (mapFn: (state: any) => K, options?: { equal?: ValueEqualityFn }) => Signal; + declare module '@reduxjs/toolkit/query' { export interface ApiModules< // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -62,6 +64,10 @@ declare module '@reduxjs/toolkit/query' { * Provides access to the api dispatch function. */ dispatch: Dispatch; + /** + * Provides access to the api useSelector function. + */ + useSelector: UseSelector; /** * Provides access to the api injector. */ @@ -86,7 +92,7 @@ export interface AngularHooksModuleOptions { /** * The version of the `useSelector` hook to be used */ - useSelector: (mapFn: (state: any) => K, options?: { equal?: ValueEqualityFn }) => Signal; + useSelector: UseSelector; }; /** * A selector creator (usually from `reselect`, or matching the same signature) @@ -128,6 +134,7 @@ export const angularHooksModule = ({ }); safeAssign(anyApi, { usePrefetch }); safeAssign(anyApi, { dispatch: hooks.dispatch }); + safeAssign(anyApi, { useSelector: hooks.useSelector }); safeAssign(anyApi, { getInjector }); return { diff --git a/packages/ngrx-rtk-query/noop-store/src/provide-noop-store-api.ts b/packages/ngrx-rtk-query/noop-store/src/provide-noop-store-api.ts index 29d2280..dd725df 100644 --- a/packages/ngrx-rtk-query/noop-store/src/provide-noop-store-api.ts +++ b/packages/ngrx-rtk-query/noop-store/src/provide-noop-store-api.ts @@ -15,7 +15,7 @@ import { type Api, setupListeners as setupListenersFn } from '@reduxjs/toolkit/q import { type AngularHooksModuleOptions, type Dispatch, type StoreQueryConfig } from 'ngrx-rtk-query/core'; -@Injectable({ providedIn: 'root' }) +@Injectable() export class ApiStore { readonly state = signal>({}); @@ -66,6 +66,7 @@ export function provideNoopStoreApi( setupListeners === false ? undefined : setupListenersFn(api.dispatch, setupListeners); return makeEnvironmentProviders([ + ApiStore, { provide: ENVIRONMENT_INITIALIZER, multi: true,