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

609
Vistas
RxJS - Tell observable to wait for other observable to emit non null value

I've got this setter which assigns a class member observable systemAreasOptions$. I do it there because it needs to wait for mappedItem$ to have had an emission which is not null. I originially had systemAreasOptions$ assigned at the class level, but it did not wait for mappedItem$. For some reason I couldn't even get the HTML to rerender when using the asyncPipe. How do I tell an observable (systemAreasOptions$ to wait for another observable (mappedItem$), instead of just assigning it where the other one emits?

public set mappedItem(mappedItem: IPermissionsMappedItem) {
    mappedItem.hydrate$Permissions().then(_ => {
        this.mappedItem$.next(mappedItem);
        this.systemAreasOptions$ = from(
            this.lookupService.SYSTEM_AREAS.toNestedLookup()
                .$promise as unknown as Observable<IPermissmissionsLookup[]>
        ).pipe(
            map(systemAreas => orderBy(systemAreas,systemArea => systemArea?.label?.toLowerCase())),
            map(systemAreas => systemAreas.map(area => ({
                ...area,
                permissions: this.getPermissionsForArea(area.id)
            }))),
            shareReplay(1),
            tap(console.log)
        );

        this._subscriptions.add(
            this.systemAreasOptions$.subscribe(
                this.systemAreasOptionsBehaviourSubject$)
        );
    });
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can combine the observables:

  • Create an observable that only emits mappedItems that aren't null
  • Emit both values only when it emits

I beleave you are looking for withLatestFrom:

higherOrder$ = mappedItemThatIsNotNull$.pipe(
  withLatestFrom(systemAreasOptions$)
) 

In your template:

higherOrder$ | async

This will yield [mappedItem, systemAreaOptions]

over 4 years ago · Santiago Trujillo 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