import { ActionReducer } from './models'; import { FeatureSelector, NestedSelectors } from './feature_creator_models'; export declare type Feature, FeatureName extends keyof AppState & string, FeatureState extends AppState[FeatureName]> = FeatureConfig & FeatureSelector & NestedSelectors; export interface FeatureConfig { name: FeatureName; reducer: ActionReducer; } declare type NotAllowedFeatureStateCheck = FeatureState extends Required ? unknown : 'optional properties are not allowed in the feature state'; /** * @description * A function that accepts a feature name and a feature reducer, and creates * a feature selector and a selector for each feature state property. * * @param featureConfig An object that contains a feature name and a feature reducer. * @returns An object that contains a feature name, a feature reducer, * a feature selector, a the selector for each feature state property. * * @usageNotes * * **With Application State** * * ```ts * interface AppState { * products: ProductsState; * } * * interface ProductsState { * products: Product[]; * selectedId: string | null; * } * * const initialState: ProductsState = { * products: [], * selectedId: null, * }; * * // AppState is passed as a generic argument * const productsFeature = createFeature({ * name: 'products', * reducer: createReducer( * initialState, * on(ProductsApiActions.loadSuccess(state, { products }) => ({ * ...state, * products, * }), * ), * }); * * const { * selectProductsState, // type: MemoizedSelector * selectProducts, // type: MemoizedSelector * selectSelectedId, // type: MemoizedSelector * } = productsFeature; * ``` * * **Without Application State** * * ```ts * const productsFeature = createFeature({ * name: 'products', * reducer: createReducer(initialState), * }); * * const { * selectProductsState, // type: MemoizedSelector, ProductsState> * selectProducts, // type: MemoizedSelector, Product[]> * selectSelectedId, // type: MemoizedSelector * } = productsFeature; * ``` */ export declare function createFeature, FeatureName extends keyof AppState & string = keyof AppState & string, FeatureState extends AppState[FeatureName] = AppState[FeatureName]>(featureConfig: FeatureConfig & NotAllowedFeatureStateCheck): Feature; export {};