search

Home  >  Q&A  >  body text

Asking for advice on rxjs execution issues

Hello, I have a scene like this.

const a = [1, 2, 3, 4, 5, 6, 7]; from(a.splice(0, 3)) .pipe( concatMap(val => { Return of(val).pipe(delay(Math.random() * 1000)); }),                                                                                                                                                                                                         RepeatWhen(completed => completed.pipe(delay(2000)))),         tap(val => { console.log(a); }),         takeWhile(val => a.length > 0) ) .subscribe(() => {});

My expectation is that a prints out [4,5,6] for the first time. Then a prints out [7] a second time.

But the code keeps printing [4,5,6,7] when running. Can't figure out why?

Can you help me find out the reason?

P粉310297406P粉310297406944 days ago1107

reply all(0)I'll reply

No reply
  • Cancelreply