Questions tagged [ngrx-effects]

Use this tag for questions related to the effects package of the ngrx platform.

ngrx/effects is a package of the ngrx platform that provides an API to model event sources as actions.

See ngrx platfrom github project from more info

https://github.com/ngrx/platform

929 questions
43
votes
2 answers

Catch error in combined pipe of pipeable rxjs operators

We've just upgraded one of our applications to Angular 5, and started to transition into lettable operators as introduced in rxjs v5.5. Because of this, we have rewritten our observable pipelines to the new syntax with the .pipe() operator. Our…
Daniel B
  • 8,770
  • 5
  • 43
  • 76
32
votes
4 answers

How to wait for 2 Actions in @ngrx/effects

Can effect wait two actions like Promise.all? Example: @Effect() pulic addUser() { return this.actions$.ofType(user.ADD) .switchMap(() => { return this.userService.add(); }) .map(() => { return new…
E. Efimov
  • 443
  • 1
  • 5
  • 10
31
votes
1 answer

Why must must ngrx / redux effects return actions? Is using a noop action like elm considered bad practice?

I'm using a redux-style state management design with Angular and ngrx/store and ngrx/effects. Whenever I don't return an action from an effect, I get an error: Cannot read property 'type' of undefined I researched the issue and found that in an…
Eeks33
  • 2,245
  • 1
  • 14
  • 17
28
votes
5 answers

ngrx effect not being called when action is dispatched from component

I am having an issue with the ngrx store not dispatching an action to the effect supposed to deal with it. Here is the component that tries to dispatch: signin() { this.formStatus.submitted = true; if (this.formStatus.form.valid) { …
balteo
  • 23,602
  • 63
  • 219
  • 412
23
votes
1 answer

ngRx state update and Effects execution order

I have my own opinion on this question, but it's better to double check and know for sure. Thanks for paying attention and trying to help. Here it is: Imagine that we're dispatching an action which triggers some state changes and also has some…
Dmytro Garastovych
  • 335
  • 1
  • 2
  • 10
22
votes
4 answers

Angular router navigation inside NgRx effect

Does the Angular router have any restrictions to be used inside an NgRx effect? I just started learning NgRx and I have the following code: @Effect() public authenticate$ = this.actions$ .ofType(authenticationActions.AUTHENTICATE) …
rbasniak
  • 4,484
  • 11
  • 51
  • 100
21
votes
5 answers

Executing code after dispatch is completed while using ngrx

In my sample Angular 2 application , I am using ngrx/store and ngrx/effects for state management. Below is one of the function in a component to add a new item. addAuthor() { this.store.dispatch(addAuthorAction(this.fg.value)); …
refactor
  • 13,954
  • 24
  • 68
  • 103
20
votes
3 answers

Where should I put business logic intended to transform data meant for the ngrx store: into effects or reducers?

My question relates to ngrx effects and reducers. I need to transform data retrieved from the backend before putting it into the ngrx store. The data retrieved from the backend is an plain array of Message (Message is a custom type in my…
balteo
  • 23,602
  • 63
  • 219
  • 412
19
votes
2 answers

Angular NgRx effects, how to pass a parameter?

I am trying to send id parameter from the dispatch to the effect, I can't find any example of this case in google. Here's the code I already have: The component: ngOnInit(): void { this.packageClass =…
nperez9
  • 326
  • 1
  • 3
  • 8
19
votes
5 answers

How to unit test this effect (with {dispatch: false})?

ngrx and unit testing beginner here. I have the following effect: @Injectable() export class NotificationEffects { @Effect({dispatch: false}) notificationShow$ = this.actions$ .ofType(notificationAction.NOTIFICATION_SHOW) .do((action:…
camden_kid
  • 12,591
  • 11
  • 52
  • 88
17
votes
2 answers

Angular ngrx - Show Loading gif

I have a side effect like this: @Effect() FetchAllOrders$ = this.actions$ .ofType(SalesOrderActions.FETCH_ALL_ORDERS) .switchMap((action: Action) => { return this.soApiService.getUsersSalesOrders(action.payload); }) …
user2859298
  • 1,373
  • 3
  • 13
  • 28
16
votes
1 answer

How to use ofType with more than 5 actions?

I have to use ofType with more than 5 actions in my effect. @Effect() applyInspectionsFilters$: Observable = this.actions$.pipe( ofType( InspectionsPageActions.applyInspectionsFilters.type, …
Sergiu Molnar
  • 865
  • 1
  • 11
  • 22
15
votes
5 answers

NgRx: dispatch multiple actions in a single effect

I need to dispatch multiple actions after calling an API request in my effect. I'm using this code at the moment to dispatch one action after API request done: changeStatus$ = createEffect(() => this.actions$.pipe( …
Rashed Bayani
  • 161
  • 1
  • 1
  • 4
15
votes
6 answers

How to attach ngrx/store with an angular router guard

I'm a beginner with ngrx/store and this is my first project using it. I have successfully set up my angular project with ngrx/store and I'm able to dispatch a load action after initializing my main component like this: ngOnInit() {…
Marco Rinck
  • 738
  • 2
  • 6
  • 17
14
votes
1 answer

angular: ngrx effects not firing

I've worked on a few Angular apps that implemented Redux (NgRx). I can't figure out my current project's issue. Actions: export class GetUserFromStorage implements Action { readonly type = UserActionTypes.GetUserFromStorage; } export class…
pax
  • 1,547
  • 2
  • 16
  • 46
1
2 3
61 62