Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Is it possible and if ok, then how to transform data inside ngrx effect?
//app.effect.ts
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import {addCityToIndex, returnCityToIndex} from './reducers/form.reducer';
import { map } from 'rxjs/operators';
import { HttpService } from './services/http.service';

@Injectable()
export class AppEffects {

  effect$ = createEffect(() =>
    this.actions$.pipe(
      ofType(addCityToIndex),
      map(data => returnCityToIndex(data))
    ), {});

  constructor(private actions$: Actions, private http: HttpService) {}
}

I need to update data, which I have in addCityToIndex (array) via http service - get property of array element, make request to service, update element and pass new array to returnCityToIndex.

Is it possible and if ok, then how to transform data inside ngrx effect?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Based on documentation

You can use a action to trigger a request and return another action witch will update your state, and your component will recive the new data in selector when the data be updated.

Ex:

  login$ = createEffect(() =>
    this.actions$.pipe(
      ofType(LoginPageActions.login),
      exhaustMap(action =>
        this.authService.login(action.credentials).pipe(
          map(user => AuthApiActions.loginSuccess({ user })),
          catchError(error => of(AuthApiActions.loginFailure({ error })))
        )
      )
    )
  );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!