UNPKG

15.3 kBTypeScriptView Raw
1import { Selector, SelectorWithProps } from './models';
2export type AnyFn = (...args: any[]) => any;
3export type MemoizedProjection = {
4 memoized: AnyFn;
5 reset: () => void;
6 setResult: (result?: any) => void;
7 clearResult: () => void;
8};
9export type MemoizeFn = (t: AnyFn) => MemoizedProjection;
10export type ComparatorFn = (a: any, b: any) => boolean;
11export type DefaultProjectorFn<T> = (...args: any[]) => T;
12export interface MemoizedSelector<State, Result, ProjectorFn = DefaultProjectorFn<Result>> extends Selector<State, Result> {
13 release(): void;
14 projector: ProjectorFn;
15 setResult: (result?: Result) => void;
16 clearResult: () => void;
17}
18/**
19 * @deprecated Selectors with props are deprecated, for more info see the {@link https://ngrx.io/guide/migration/v12#ngrxstore migration guide}
20 */
21export interface MemoizedSelectorWithProps<State, Props, Result, ProjectorFn = DefaultProjectorFn<Result>> extends SelectorWithProps<State, Props, Result> {
22 release(): void;
23 projector: ProjectorFn;
24 setResult: (result?: Result) => void;
25 clearResult: () => void;
26}
27export declare function isEqualCheck(a: any, b: any): boolean;
28export declare function resultMemoize(projectionFn: AnyFn, isResultEqual: ComparatorFn): MemoizedProjection;
29export declare function defaultMemoize(projectionFn: AnyFn, isArgumentsEqual?: typeof isEqualCheck, isResultEqual?: typeof isEqualCheck): MemoizedProjection;
30export declare function createSelector<State, S1, Result>(s1: Selector<State, S1>, projector: (s1: S1) => Result): MemoizedSelector<State, Result, typeof projector>;
31export declare function createSelector<State, S1, S2, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, projector: (s1: S1, s2: S2) => Result): MemoizedSelector<State, Result, typeof projector>;
32export declare function createSelector<State, S1, S2, S3, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, s3: Selector<State, S3>, projector: (s1: S1, s2: S2, s3: S3) => Result): MemoizedSelector<State, Result, typeof projector>;
33export declare function createSelector<State, S1, S2, S3, S4, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, s3: Selector<State, S3>, s4: Selector<State, S4>, projector: (s1: S1, s2: S2, s3: S3, s4: S4) => Result): MemoizedSelector<State, Result, typeof projector>;
34export declare function createSelector<State, S1, S2, S3, S4, S5, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, s3: Selector<State, S3>, s4: Selector<State, S4>, s5: Selector<State, S5>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5) => Result): MemoizedSelector<State, Result, typeof projector>;
35export declare function createSelector<State, S1, S2, S3, S4, S5, S6, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, s3: Selector<State, S3>, s4: Selector<State, S4>, s5: Selector<State, S5>, s6: Selector<State, S6>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6) => Result): MemoizedSelector<State, Result, typeof projector>;
36export declare function createSelector<State, S1, S2, S3, S4, S5, S6, S7, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, s3: Selector<State, S3>, s4: Selector<State, S4>, s5: Selector<State, S5>, s6: Selector<State, S6>, s7: Selector<State, S7>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, s7: S7) => Result): MemoizedSelector<State, Result, typeof projector>;
37export declare function createSelector<State, S1, S2, S3, S4, S5, S6, S7, S8, Result>(s1: Selector<State, S1>, s2: Selector<State, S2>, s3: Selector<State, S3>, s4: Selector<State, S4>, s5: Selector<State, S5>, s6: Selector<State, S6>, s7: Selector<State, S7>, s8: Selector<State, S8>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, s7: S7, s8: S8) => Result): MemoizedSelector<State, Result, typeof projector>;
38export declare function createSelector<Selectors extends Record<string, Selector<State, unknown>>, State = Selectors extends Record<string, Selector<infer S, unknown>> ? S : never, Result extends Record<string, unknown> = {
39 [Key in keyof Selectors]: Selectors[Key] extends Selector<State, infer R> ? R : never;
40}>(selectors: Selectors): MemoizedSelector<State, Result, never>;
41export declare function createSelector<State, Slices extends unknown[], Result>(...args: [...slices: Selector<State, unknown>[], projector: unknown] & [
42 ...slices: {
43 [i in keyof Slices]: Selector<State, Slices[i]>;
44 },
45 projector: (...s: Slices) => Result
46]): MemoizedSelector<State, Result, (...s: Slices) => Result>;
47/**
48 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
49 */
50export declare function createSelector<State, Props, S1, Result>(s1: SelectorWithProps<State, Props, S1>, projector: (s1: S1, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
51/**
52 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
53 */
54export declare function createSelector<State, Props, S1, S2, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, projector: (s1: S1, s2: S2, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
55/**
56 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
57 */
58export declare function createSelector<State, Props, S1, S2, S3, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, s3: SelectorWithProps<State, Props, S3>, projector: (s1: S1, s2: S2, s3: S3, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
59/**
60 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
61 */
62export declare function createSelector<State, Props, S1, S2, S3, S4, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, s3: SelectorWithProps<State, Props, S3>, s4: SelectorWithProps<State, Props, S4>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
63/**
64 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
65 */
66export declare function createSelector<State, Props, S1, S2, S3, S4, S5, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, s3: SelectorWithProps<State, Props, S3>, s4: SelectorWithProps<State, Props, S4>, s5: SelectorWithProps<State, Props, S5>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
67/**
68 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
69 */
70export declare function createSelector<State, Props, S1, S2, S3, S4, S5, S6, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, s3: SelectorWithProps<State, Props, S3>, s4: SelectorWithProps<State, Props, S4>, s5: SelectorWithProps<State, Props, S5>, s6: SelectorWithProps<State, Props, S6>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
71/**
72 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
73 */
74export declare function createSelector<State, Props, S1, S2, S3, S4, S5, S6, S7, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, s3: SelectorWithProps<State, Props, S3>, s4: SelectorWithProps<State, Props, S4>, s5: SelectorWithProps<State, Props, S5>, s6: SelectorWithProps<State, Props, S6>, s7: SelectorWithProps<State, Props, S7>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, s7: S7, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
75/**
76 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
77 */
78export declare function createSelector<State, Props, S1, S2, S3, S4, S5, S6, S7, S8, Result>(s1: SelectorWithProps<State, Props, S1>, s2: SelectorWithProps<State, Props, S2>, s3: SelectorWithProps<State, Props, S3>, s4: SelectorWithProps<State, Props, S4>, s5: SelectorWithProps<State, Props, S5>, s6: SelectorWithProps<State, Props, S6>, s7: SelectorWithProps<State, Props, S7>, s8: SelectorWithProps<State, Props, S8>, projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, s7: S7, s8: S8, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
79export declare function createSelector<State, Slices extends unknown[], Result>(selectors: Selector<State, unknown>[] & [
80 ...{
81 [i in keyof Slices]: Selector<State, Slices[i]>;
82 }
83], projector: (...s: Slices) => Result): MemoizedSelector<State, Result, (...s: Slices) => Result>;
84/**
85 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
86 */
87export declare function createSelector<State, Props, S1, Result>(selectors: [SelectorWithProps<State, Props, S1>], projector: (s1: S1, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
88/**
89 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
90 */
91export declare function createSelector<State, Props, S1, S2, Result>(selectors: [
92 SelectorWithProps<State, Props, S1>,
93 SelectorWithProps<State, Props, S2>
94], projector: (s1: S1, s2: S2, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
95/**
96 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
97 */
98export declare function createSelector<State, Props, S1, S2, S3, Result>(selectors: [
99 SelectorWithProps<State, Props, S1>,
100 SelectorWithProps<State, Props, S2>,
101 SelectorWithProps<State, Props, S3>
102], projector: (s1: S1, s2: S2, s3: S3, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
103/**
104 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
105 */
106export declare function createSelector<State, Props, S1, S2, S3, S4, Result>(selectors: [
107 SelectorWithProps<State, Props, S1>,
108 SelectorWithProps<State, Props, S2>,
109 SelectorWithProps<State, Props, S3>,
110 SelectorWithProps<State, Props, S4>
111], projector: (s1: S1, s2: S2, s3: S3, s4: S4, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
112/**
113 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
114 */
115export declare function createSelector<State, Props, S1, S2, S3, S4, S5, Result>(selectors: [
116 SelectorWithProps<State, Props, S1>,
117 SelectorWithProps<State, Props, S2>,
118 SelectorWithProps<State, Props, S3>,
119 SelectorWithProps<State, Props, S4>,
120 SelectorWithProps<State, Props, S5>
121], projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
122/**
123 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
124 */
125export declare function createSelector<State, Props, S1, S2, S3, S4, S5, S6, Result>(selectors: [
126 SelectorWithProps<State, Props, S1>,
127 SelectorWithProps<State, Props, S2>,
128 SelectorWithProps<State, Props, S3>,
129 SelectorWithProps<State, Props, S4>,
130 SelectorWithProps<State, Props, S5>,
131 SelectorWithProps<State, Props, S6>
132], projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
133/**
134 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
135 */
136export declare function createSelector<State, Props, S1, S2, S3, S4, S5, S6, S7, Result>(selectors: [
137 SelectorWithProps<State, Props, S1>,
138 SelectorWithProps<State, Props, S2>,
139 SelectorWithProps<State, Props, S3>,
140 SelectorWithProps<State, Props, S4>,
141 SelectorWithProps<State, Props, S5>,
142 SelectorWithProps<State, Props, S6>,
143 SelectorWithProps<State, Props, S7>
144], projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, s7: S7, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
145/**
146 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
147 */
148export declare function createSelector<State, Props, S1, S2, S3, S4, S5, S6, S7, S8, Result>(selectors: [
149 SelectorWithProps<State, Props, S1>,
150 SelectorWithProps<State, Props, S2>,
151 SelectorWithProps<State, Props, S3>,
152 SelectorWithProps<State, Props, S4>,
153 SelectorWithProps<State, Props, S5>,
154 SelectorWithProps<State, Props, S6>,
155 SelectorWithProps<State, Props, S7>,
156 SelectorWithProps<State, Props, S8>
157], projector: (s1: S1, s2: S2, s3: S3, s4: S4, s5: S5, s6: S6, s7: S7, s8: S8, props: Props) => Result): MemoizedSelectorWithProps<State, Props, Result, typeof projector>;
158export declare function defaultStateFn(state: any, selectors: Selector<any, any>[] | SelectorWithProps<any, any, any>[], props: any, memoizedProjector: MemoizedProjection): any;
159export type SelectorFactoryConfig<T = any, V = any> = {
160 stateFn: (state: T, selectors: Selector<any, any>[], props: any, memoizedProjector: MemoizedProjection) => V;
161};
162export declare function createSelectorFactory<T = any, V = any>(memoize: MemoizeFn): (...input: any[]) => MemoizedSelector<T, V>;
163export declare function createSelectorFactory<T = any, V = any>(memoize: MemoizeFn, options: SelectorFactoryConfig<T, V>): (...input: any[]) => MemoizedSelector<T, V>;
164/**
165 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
166 */
167export declare function createSelectorFactory<T = any, Props = any, V = any>(memoize: MemoizeFn): (...input: any[]) => MemoizedSelectorWithProps<T, Props, V>;
168/**
169 * @deprecated Selectors with props are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/2980 Github Issue}
170 */
171export declare function createSelectorFactory<T = any, Props = any, V = any>(memoize: MemoizeFn, options: SelectorFactoryConfig<T, V>): (...input: any[]) => MemoizedSelectorWithProps<T, Props, V>;
172export declare function createFeatureSelector<T>(featureName: string): MemoizedSelector<object, T>;
173/**
174 * @deprecated Feature selectors with a root state are deprecated, for more info see {@link https://github.com/ngrx/platform/issues/3179 Github Issue}
175 */
176export declare function createFeatureSelector<T, V>(featureName: keyof T): MemoizedSelector<T, V>;