Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda