Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

408
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda