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

235
Views
Darse de baja de un observable cuando la condición es verdadera en angular

Estoy tratando de cerrar una ventana emergente después de 5 segundos cuando se carga, pero la suscripción finaliza antes, así que quiero cancelar la suscripción cuando la variable cargada es verdadera.

 this.closed = false; this.loaded$.subscribe(loaded => { if (loaded) { setTimeout(() => { this.modalService.dismissActiveModal(); }, 5000); } }).unsubscribe(); }
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

this.closed = false; // define the subscription const subscription: Subscription = this.loaded$.subscribe(loaded => { if (loaded) { setTimeout(() => { this.modalService.dismissActiveModal(); subscription.unsubscribe(); // unsubscribe here }, 5000); } });

¿Qué tal esto?

about 4 years ago · Santiago Trujillo Report

0

this.closed = false; this.loaded$ .pipe( filter(loaded => loaded), switchMap(_ => interval(5000)), take(1), tap(_ => this.modalService.dismissActiveModal()) ) .subscribe();
about 4 years ago · Santiago Trujillo 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!