@@ -114,6 +114,14 @@ export interface RootStoreConfig<T, V extends Action = Action>
114114 runtimeChecks ?: Partial < RuntimeChecks > ;
115115}
116116
117+ /**
118+ * An object with the name and the reducer for the feature.
119+ */
120+ export interface FeatureSlice < T , V extends Action = Action > {
121+ name : string ;
122+ reducer : ActionReducer < T , V > ;
123+ }
124+
117125@NgModule ( { } )
118126export class StoreModule {
119127 static forRoot < T , V extends Action = Action > (
@@ -192,15 +200,36 @@ export class StoreModule {
192200 reducer : ActionReducer < T , V > | InjectionToken < ActionReducer < T , V > > ,
193201 config ?: StoreConfig < T , V > | InjectionToken < StoreConfig < T , V > >
194202 ) : ModuleWithProviders < StoreFeatureModule > ;
203+ static forFeature < T , V extends Action = Action > (
204+ slice : FeatureSlice < T , V > ,
205+ config ?: StoreConfig < T , V > | InjectionToken < StoreConfig < T , V > >
206+ ) : ModuleWithProviders < StoreFeatureModule > ;
195207 static forFeature (
196- featureName : string ,
197- reducers :
208+ featureNameOrSlice : string | FeatureSlice < any , any > ,
209+ reducersOrConfig ? :
198210 | ActionReducerMap < any , any >
199211 | InjectionToken < ActionReducerMap < any , any > >
200212 | ActionReducer < any , any >
201- | InjectionToken < ActionReducer < any , any > > ,
213+ | InjectionToken < ActionReducer < any , any > >
214+ | StoreConfig < any , any >
215+ | InjectionToken < StoreConfig < any , any > > ,
202216 config : StoreConfig < any , any > | InjectionToken < StoreConfig < any , any > > = { }
203217 ) : ModuleWithProviders < StoreFeatureModule > {
218+ let featureName : string ;
219+ let reducers :
220+ | ActionReducerMap < any , any >
221+ | InjectionToken < ActionReducerMap < any , any > >
222+ | ActionReducer < any , any >
223+ | InjectionToken < ActionReducer < any , any > > ;
224+ if ( typeof featureNameOrSlice === 'string' ) {
225+ featureName = featureNameOrSlice ;
226+ reducers = reducersOrConfig as any ;
227+ } else {
228+ featureName = featureNameOrSlice . name ;
229+ reducers = featureNameOrSlice . reducer ;
230+ config = ( reducersOrConfig as any ) ?? { } ;
231+ }
232+
204233 return {
205234 ngModule : StoreFeatureModule ,
206235 providers : [
0 commit comments