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

68
Views
return empty ajaxAsObservable

I have this code

 allEditChanges
                    .debounce(250)
                    .distinctUntilChanged()
                    .flatMapLatest(function (text) {return  $.ajaxAsObservable({url:..., data:....} }).subscribe()

I need to make this conditionall so sometimes just omit the request. I tried this way

 allEditChanges
 .debounce(250)
 .distinctUntilChanged(
 .flatMapLatest(function (text) {if(myFlag){
 return  $.ajaxAsObservable({url:..., data:....}))
}else{
return $.ajaxAsObservable({}); } }).subscribe()

but when myFlag is true , calls request to the current page. Question how to omit the request ? How to not call any request on some condition

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

0

You can use filter

allEditChanges
   .debounce(250)
   .distinctUntilChanged()
   .filter(() => !myFlag)
   .flatMapLatest(function (text) {return  $.ajaxAsObservable({url:..., data:....} })
   .subscribe()

Or return Rx.Observable.empty()

allEditChanges
   .debounce(250)
   .distinctUntilChanged()
   .filter(() => !myFlag)
   .flatMapLatest(function (text) {
       if(myFlag){
         return Rx.Observable.empty();
       }
       return  $.ajaxAsObservable({url:..., data:....} })
   .subscribe()
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!