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

109
Vistas
forkJoin indefinido cuando se comparte componente (y combinando variables booleanas)

Tengo un servicio usado en muchos componentes y necesito compartir el resultado de un forkjoin, pero el componente viene como indefinido

Mi capa de lógica de servicio

 @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$)), ); } }

En mi componente:

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

Resultado en consola: ingrese la descripción de la imagen aquí

Necesito volver a los componentes si hasError$ es verdadero o falso.

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