Questions tagged [ngrx]

NgRx is a reactive state management library for Angular based on flux design pattern.

NgRx provides a set of reactive libraries for Angular.

It includes:

Store: RxJS powered state management for Angular applications, inspired by Redux

Effects: RxJS powered side effect model for @ngrx/store

Entity: Entity State adapter for managing record collections.

Router-Store: Bindings to connect the Angular Router with @ngrx/store

Store-DevTools: Developer Tools for @ngrx/store

DB: RxJS powered IndexedDB for Angular apps


See Official Docs for more Info

4430 questions
83
votes
3 answers

TypeError: Cannot assign to read only property '0' of object '[object Array]' in typescript

I am working on angular 8. I have a page that displays a table. The table displays data from an object array taskList which the component gets as an @Input(). I have a sorting function on the columns of this table. I also have a delete option on…
Amruta
  • 1,295
  • 1
  • 13
  • 24
78
votes
11 answers

How to get current value of State object with @ngrx/store?

My service class, before calling a web service, needs to get a property called dataForUpdate from my state. Currently, I'm doing it like this: constructor(public _store: Store < AppState > , public _APIService: APIService) { const store$ =…
Philippe sillon
  • 1,572
  • 2
  • 14
  • 20
71
votes
4 answers

Angular what's the meaning of these three dots in @NGRX

What do these three dots mean exactly, and why do I need them? export function leadReducer(state: Lead[]= [], action: Action { switch(action.type){ case ADD_LEAD: return [...state, action.payload]; case REMOVE_LEAD: …
Anouar Mokhtari
  • 2,084
  • 4
  • 23
  • 23
68
votes
12 answers

NgRX effects - Type 'Observable' is not assignable to type 'Observable'

While working with NgRX 8 my colleagues and me are frequently facing a weird error message when implementing the effects. Type 'Observable' is not assignable to type 'Observable | ((...args: any[]) => Observable)' It is…
Felix Lemke
  • 6,189
  • 3
  • 40
  • 67
68
votes
2 answers

How to choose the Redux state shape for an app with list/detail views and pagination?

Imagine I have a number of entries(say, users) in my database. I also have two routes, one for list, other for detail(where you can edit the entry). Now I'm struggling with how to approach the data structure. I'm thinking of two approaches and a…
fxck
  • 4,898
  • 8
  • 56
  • 94
64
votes
3 answers

What are benefits of using store (ngrx) in angular 2

I'm working on a angular 1.x.x project and thinking about upgrading my code to angular 2. Now in my project I have many services(factory) for handling data which almost keep data in js arrays(both cache and storage) and process these data by using…
Vu Quyet
  • 1,675
  • 1
  • 16
  • 22
62
votes
2 answers

Understanding the purpose of the ngrx router-store project as compared to only using the angular 2 router

I am in reference to the router-store ngrx project (https://github.com/ngrx/router-store). I am not clear how to use this project... For instance let's take the following sample from the project documentation: store.dispatch(go(['/path', {…
balteo
  • 23,602
  • 63
  • 219
  • 412
61
votes
2 answers

RxJS - Multiple sources for .withLatestFrom

I want to merge the latest emitted values from multiple Observables, so right now I'm using .withLatestFrom. Except, it nests the data together in nested arrays instead of pushing the data into a new array value. Example code below. Any ideas on how…
Preda70R
  • 958
  • 1
  • 9
  • 10
61
votes
5 answers

SwitchMap vs MergeMap in the #ngrx example

Below is code from the Ngrx example: https://github.com/ngrx/example-app/blob/master/src/effects/book.ts My question is why in the first @Effect, it uses switchMap while the others use mergeMap. Is that because the first @Effect is dealing with…
Tuong Le
  • 18,533
  • 11
  • 50
  • 44
54
votes
6 answers

how to subscribe to action success callback using ngrx and effects

I'm trying to do simple thing - after some entity saved (using http request) I want to navigate back to list route. The problem is : how to subscribe to success action (or may be reducer or effect?) here is my actions code: static SAVE_POST =…
happyZZR1400
  • 2,387
  • 3
  • 25
  • 43
53
votes
3 answers

NgrxStore and Angular - Use the async pipe massively or subscribe just once in the constructor

I am starting to look at ngrx Store and I see the convenience to use the Angular async pipe. At the same time I am not sure whether using the Angular async pipe massively is a good choice. I make a simple example. Let's assume that in the same…
Picci
  • 16,775
  • 13
  • 70
  • 113
51
votes
6 answers

dispatch multiple actions in one effect

I would like to dispatch two actions in one effect. Currently I have to declare two effects to achieve this : // first effect @Effect() action1$ = this.actions$ .ofType(CoreActionTypes.MY_ACTION) .map(res => { return { type: "ACTION_ONE"} …
Lev
  • 13,856
  • 14
  • 52
  • 84
47
votes
1 answer

Angular2 router VS ui-router-ng2 VS ngrx router

What are the benefits and disadvantages of using ui-router-ng2 instead of the new Angular2 router? In the past i used ui-router with Angular 1.x instead of using ngRoute, because i need better support for nested states/routes. So now, what about…
smartmouse
  • 13,912
  • 34
  • 100
  • 166
45
votes
1 answer

What is the purpose of ngrx/effects library?

I have failed to find any usefull information about this library or what is the purpose of it. It seems like ngrx/effects explain this library to developers who already know this concept and gives a bigginer example on how to code. My…
Stav Alfi
  • 13,139
  • 23
  • 99
  • 171
44
votes
6 answers

how can i run a specific angular spec test file in NX workspace?

is there any way to run an specific angular spec test file in Nx work space? Recently i moved my Angular 4 cli application into Nx work space. Previously i used fdescribe to achieve this functionality. So please suggest me if there is any…
Raj Kumar
  • 583
  • 2
  • 5
  • 9
1
2 3
99 100