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

250
Views
Mapa de cambio de sujeto de Rxjs para llamar a otro observable

Estoy tratando de llamar a otro observable en cada valor emitido en el sujeto.

Mi problema ahora es que el primer valor emitido al subject activa switchMap y llama a confirmCsvUpload(...) , pero cada siguiente valor emitido switchMap pero no confirmCsvUpload(...) .

¿Alguien puede averiguar por qué no está llamando a la función?

 // Subject private _confirmCsvUpload = new Subject<{ account: Account, previewData: PreviewData[], previewId: string }>(); // Subscription to the Subject this._confirmCsvUpload.pipe( switchMap(previewData => this._uploadCsvService.confirmCsvUpload(previewData.account, previewData.previewData, previewData.previewId)) ).subscribe(); // Function which emits value to the subject (Not the function who gets called in the switchMap()) confirmCsvUpload(): void { this._confirmCsvUpload.next({ account: this.account, previewData: this._previewData, previewId: this.getPreviewIdFromRoute() }); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intento reproducir tu escenario con:

 private _confirm$ = new Subject(); private _destroy$ = new Subject(); ngOnInit() { this._confirm$ .pipe( takeUntil(this._destroy$), tap((v) => console.log('[SUB]', v)), switchMap((v: any) => this.secondCall()) ) .subscribe(); } secondCall() { console.log('[SECOND CALL]'); return of(); } callSub() { console.log('[NEXT VALUE]'); this._confirm$.next('value'); } ngOnDestroy() { this._destroy$.next(null); this._destroy$.complete(); console.log('[NG ON DESTROY]'); }

Registro de consola con 2 llamadas:

 [NEXT VALUE] [SUB] value [SECOND CALL]

-- segunda vez:

 [NEXT VALUE] [SUB] value [SECOND CALL]
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!