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

407
Views
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 answers
Answer question

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 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!