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

190
Views
RxJS - Observable no se ejecuta cuando takeUntil y su notificador observable emite en el mismo observable interno

Código:

 const main$ = of(true); const int$ = interval(2000); const notifier$ = new Subject(); main$.pipe( switchMap(() => int$.pipe( tap(() => { // some logic for when to trigger notifier notifier$.next(1); // after some intervals }), takeUntil(notifier$), )), tap(() => {// never reach here}) ).subscribe(() => { // never reach here });

En el código anterior, takeUntil detiene el interval cuando el notifier$ emite pero no llama a subscribe() nunca y nunca llega a los operadores, por ejemplo. tap() (ver código) después de takeUntil . ¿Porqué es eso? ¿Me estoy perdiendo de algo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

el operador takeUntil emite los valores emitidos por un Observable fuente que sería su Observable main$ hasta que un Observable notificador emita un valor como lo está haciendo el Sujeto notifier$ . Por lo tanto, después de que notifier$ emita un valor en la next llamada dentro de la primera iteración de su intervalo, takeUntil evita que el Observable subyacente se propague más, lo que significa que nunca se alcanzará al operador tap .

Si estuviera utilizando una implementación diferente para su notifier$ como el timer , podría observar que se llamará al operador de tap hasta que transcurra el temporizador y, por lo tanto, active el takeUntil .

 const main$ = of(true); const int$ = interval(2000); const notifier$ = timer(10000); main$.pipe( switchMap(() => int$.pipe( tap(() => { // some logic for when to trigger notifier }), takeUntil(notifier$), )), tap((result) => { console.log(result) }) ).subscribe((result) => { // will be reached four times. }); }
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!