Several slices of the global state in NGRX - is this how they are registered for standalone app?
In the official docs - I didn’t find an example, I didn’t search well, maybe
import {
authFeatureKey,
authReducer,
} from './components/auth/store/reducers/auth.reducer';
import { provideEffects } from '@ngrx/effects';
import * as authEffects from './components/auth/store/effects/auth.effect';
import * as currentUserEffects from './components/auth/store/effects/current-user.effect';
import * as feedEffects from './components/feeds/store/effects/feed.effect';
import { CurrentUserAction } from './components/auth/store/actions';
import { IGlobalState } from './interfaces';
import {
feedsFeatureKey,
feedsReducer,
} from './components/feeds/store/reducers';
function initializeApplication(store: Store<IGlobalState>): () => void {
return (): void => store.dispatch(CurrentUserAction.get());
}
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideStore(),
provideState({ name: authFeatureKey, reducer: authReducer }),
provideState({ name: feedsFeatureKey, reducer: feedsReducer }),
provideEffects(authEffects, currentUserEffects, feedEffects),
provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() }),
provideHttpClient(withInterceptors([loginInterceptor])),
// we can provide the desired Storage (localStorage, sessionStorage, etc.) to our Angular application
{
provide: STORAGE,
useValue: localStorage,
},
{
provide: APP_INITIALIZER,
useFactory: initializeApplication,
multi: true,
deps: [Store],
},
],
};