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

150
Views
How to export rxjs Subject with pre-defined pipe operators?

I want to export rxjs Subject with some pre-defined behavior (via pipe()).

e.g. I want to export a subject that do console.log on each new value:

export const subj$ = new Subject()
  .pipe(
    tap(() => console.log('updated')
  )

This works, and I'm able to subscribe() to subj$.

The problem is that this way it's impossible to do subj$.next('foo').

Of course I can export two variables for subscribe() and for next(), but that's supper silly

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

0

Actually you cannot do this. Because pipe converts Subject to Observable and this record is similar to this: new Subject().asObservable().

But, you can create your own Subject, for example from source (https://github.com/ReactiveX/rxjs/blob/master/src/internal/BehaviorSubject.ts). And make any function to invoke inside.

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!