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

120
Views
Varibles cannot change while I use rxjs operator

const a = [1, 2, 3, 4, 5, 6, 7,8];
rxjs.from(a.splice(0, 3))
      .pipe(
        rxjs.concatMap(val => {
          return rxjs.of(val).pipe(rxjs.delay(Math.random() * 1000));
        }),
        rxjs.repeatWhen(completed => completed.pipe(rxjs.delay(2000))),
        rxjs.tap(val => {
          console.log(a);
        }),
        rxjs.takeWhile(val => a.length > 0)
      )
      .subscribe(() => {});
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/7.5.5/rxjs.umd.min.js"></script>

In above,I suppose it will console.log [4,5,6],and then [7,8],and then stop,but while it always console.log [4,5,6]。 I wonder know why it is and how to achive I want. Thanks!

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

0

You have to call splice inside the pipe

const a = [1, 2, 3, 4, 5, 6, 7,8];
rxjs.from(a.splice(0, 3))
      .pipe(
        rxjs.concatMap(val => {
          return rxjs.of(val).pipe(rxjs.delay(Math.random() * 1000));
        }),
        rxjs.repeatWhen(completed => completed.pipe(rxjs.delay(2000))),
        rxjs.tap(val => {
          console.log(a);
          a.splice(0, 3);
        }),
        rxjs.takeWhile(val => a.length > 0)
      )
      .subscribe(() => {});
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/7.5.5/rxjs.umd.min.js"></script>

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!