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

409
Visualizações
Promise inside NGRX effect

I have been struggling to make this work. I am listening to setTeam action and checking if the image is null from the payload. If it's null, call the API and get blob and convert it to base64 and dispatch update action.

The code looks like this.

fetchImage = createEffect(() =>
    this.actions$.pipe(
        ofType(teamActions.setTeam),
        withLatestFrom(this.store.pipe(select(selectTeam))),
        switchMap(([payload]) => {
            if (!payload.team.teamLogoImage) {
                return this.teamService.getImage(payload.team.id)
                    .pipe(map((value => {
                        ImageUtils.getBase64(value); //returns promise
                        return teamActions.updateTeamLogoImage({teamLogoImage: val});
                    })))
            }
        })
    ));

The problem here is ImageUtils.getBase64 returns Promise and I need to wait till this promise is resolved before dispatching updateTeamLogoImage action. How can this be achieved?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can put the Promise in RxJS from function and handle ImageUtils.getBase64 as Observable in pipe.

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