Questions tagged ngrx-store

Explore the latest questions and answers asked by our top developers.

Angular is giving State’ is not assignable to type ‘ActionReducer<State, Action>’ error

Above error is thrown by VSCode IDE, while trying to combine reducers in one file. import { ActionReducerMap } from ‘@ngrx/store’; import { employeeReducer, State } from ‘./store/reducers/employee.reducer’; export interface AppState { employee: State; } export const appReducer: ActionReducerMap<AppState> = { employee: employeeReducer, // Getting IDE error here }; My action looks like import { […]

By Rajath
Categorized as angular, angular13, ngrx-reducers, ngrx-store Tagged , , ,

NgRx Data service Update removes object prototype instead of updating the changed fields

When my NgRx DefaultDataService updates, it removes the type/prototype of the objects in the store. The objects are no longer of type Todo, but are simple objects with no prototype. The objects come from the server as json objects conforming to the Todo interface. I pipe them to be entered into the store as Todo […]

By RedAlex
Categorized as angular, javascript, ngrx, ngrx-entity, ngrx-store Tagged , , , ,

Why ‘subscribe’ doesn’t trigger when chain pipe with ‘select’ from NgRx in Angular

I have two examples of code, and I can’t understand why second example is not working. For me they are equivalent. First example is working: this.someValue$ = select(someValue), takeUntil(this.ngUnsubscribe$$) ); this.someValue$.subscribe(someValue => this.someValue= someValue) And second example is not working when the store has changes, it triggers only once: select(someValue), takeUntil(this.ngUnsubscribe$$) ).subscribe(someValue => […]

By Experimenter
Categorized as angular, ngrx, ngrx-store, ngrx-store-4.0 Tagged , , ,

Store FormGroup in @ngrx/store

In an Angular application I have a page with multiple tabs (using ngx-bootstrap). Each tab contains a FormGroup and multiple FormControls. I would like to persist the whole FormGroup in a @ngrx/store rather than its value, as my goals is to restore also the controls’ state (disabled, required, etc.) when navigating back to the same […]

By Francesco
Categorized as angular, formgroups, ngrx-entity, ngrx-store Tagged , , ,

NGRX router-store: selectCurrentRoute selector undefined

I’m trying to use the selectCurrentRoute selector, but I only get undefined. export interface AppState { routerState: RouterReducerState<RouterStateUrl> } export const reducers: ActionReducerMap<AppState> = { routerState: routerReducer }; export const selectRouterState = createFeatureSelector<RouterReducerState<RouterStateUrl>>(‘routerState’); export const { selectCurrentRoute } = getSelectors(selectRouterState); export const getCurrentRoute = createSelector(selectRouterState, selectCurrentRoute); —— .select(routerFromSelector.getCurrentRoute) .subscribe((route) => console.log(route)); core.module.ts StoreModule.forRoot(reducers), StoreRouterConnectingModule.forRoot({ […]

By Max
Categorized as angular, angular-routing, ngrx, ngrx-store Tagged , , ,

Ngrx: How to simplify the definition of actions?

Is there any way to simplify the definition of actions so that we don’t need to repeat code over and over again? Working with Ngrx we have to work with actions all the time. In my situation, the most time each action does have a "Do"-Action, a "Success"-Action and a "Failure"-Action. In my situation each […]

By julianpoemp
Categorized as angular, ngrx, ngrx-store, typescript Tagged , , ,

Store<AppState> undefined within angular spec file

Issue: store is undefined within angular spec file no matter whether the initial state is provided or not. As a whole, I am not entirely sure what could be causing this issue. Followed the NGRX testing documentation to implement mock store. store variable should at least be defined to show an empty object if anything […]

"Cannot freeze" when adding web3 to ngrx state

core.mjs:6469 ERROR TypeError: Cannot freeze at Function.freeze (<anonymous>) at freeze (ngrx-store.mjs:824) at ngrx-store.mjs:838 at Array.forEach (<anonymous>) at freeze (ngrx-store.mjs:826) at ngrx-store.mjs:838 at Array.forEach (<anonymous>) at freeze (ngrx-store.mjs:826) at ngrx-store.mjs:838 at Array.forEach (<anonymous>) core.mjs:6469 ERROR TypeError: Cannot read properties of undefined (reading ‘vaults’) at vaultState (vault.selectors.ts:6) at ngrx-store.mjs:600 at (<anonymous>) at defaultStateFn (ngrx-store.mjs:600) at ngrx-store.mjs:700 […]

By Darthg8r
Categorized as angular, ngrx-store, web3, web3js Tagged , , ,

MemoizedSelector is not assignable

I’m trying to get ngrx/store up and running in a new Angular app. I’m trying to follow the pattern of having an effect do the http fetching. The idea is to dispatch FetchVaults, have effect fetch data from server, and then it dispatches a success action that populates state. The compile error that’s occuring is: […]

By Darthg8r
Categorized as angular, ngrx-effects, ngrx-store, typescript Tagged , , ,

Reducer appears to not be resolving properly

This is probably pretty basic. Learning ngrx for the first time, really. I’m not getting an @ngrx/forms reducer. I think it’s not resolving properly. If I *ngIf="vehicleForm$ | async as vehicleForm" it appears to be resolving to false. This is a relatively new project and I’m following the @ngrx/forms installation guide, but one crucial thing […]

By Bluebaron
Categorized as angular, ngrx, ngrx-forms, ngrx-store Tagged , , ,
1 2 3 24

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us