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

111
Visualizações
forkJoin undefined when share component (and combining boolean variables)

I have a service used in many components and I need to share the result of a forkjoin, but the component is coming as undefined

My service logic layer

         @Injectable({
                providedIn: 'root'
            })
            
            export class CoreStateService {
                private subject = new BehaviorSubject<any>([]);
                hasError$: Observable<any> = this.subject.asObservable();

                constructor(private api: HomeGuardService) {}
                
                    public verifyFailed(): Observable<any>{
                    return forkJoin([this.api.getPerfilNew$, this.api.getPosicaoConsolidada()])
                         .pipe(
                            catchError(err => {
                                this.statusError = err.status;
                                console.log('--->', this.statusError);
                                return of([]); 
                            }),
                            map(([perfilInvestors, position]) => {
                                this.perfilInvestors = perfilInvestors;
                                this.investments = position;
                                //verify if perfil failed
                                if (this.statusError) {
                                    this.perfilFailed = true
                                } else {
                                    this.perfilFailed = false
                                }
                                //verify if  investments failed
                                if (this.investments) {
                                    this.hasInvestiments = true;
                                }
                                //combine investments and statusError
                                this.hasError$ = combineLatest([this.statusError, this.hasInvestiments])
                                    .pipe(
                                        map(([statusError, hasInvestiments]) => statusError && !hasInvestiments)
                                    );
                            }),
                            tap(hasError$ => this.subject.next(hasError$)),
                        );
                }
    }

In my component:

   constructor(private coreState: CoreStateService) {}
    
public ngOnInit() {
        this.coreState.subscribe(res => {
            console.log(res)
        })
    }

Result in console: enter image description here

I Need to return to components if hasError$ is true or false.

about 4 years ago · Juan Pablo Isaza
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