1. First, make sure you have imported the necessary NgRx modules and your reducers and effects.个
import { provideState } from '@ngrx/store';
import { provideEffects } from '@ngrx/effects';
import { appReducer } from './app.reducer';
import { anotherFeatureReducer } from './another-feature.reducer';
import { AppEffects } from './app.effects';
import { AnotherEffects } from './another.effects';
2.In your app module, use the provideState() function to provide your root reducers个
import { provideState } from '@ngrx/store';
@NgModule({
imports: [
//Remove StoreModule.forRoot()
//Remove EffectsModule.forRoot()
// Add provideState() to provide your root reducers
provideState({
app: appReducer,
anotherFeatureName: anotherFeatureReducer,
}),
],
})
export class AppModule {}
3. Similarly, use the provideEffects() function to provide your root effects个
import { provideEffects } from '@ngrx/effects';
@NgModule({
imports: [
//Remove StoreModule.forRoot()
//Remove EffectsModule.forRoot()
// Add provideState() to provide your root reducers
provideState({
app: appReducer,
anotherFeatureName: anotherFeatureReducer,
}),
// Add provideEffects() to provide your root effects
provideEffects([AppEffects, AnotherEffects]),
],
})
export class AppModule {}