2

Say you do something like:

Rx.Observable.range(1, 5).bufferWithCount(2, 1).subscribe(console.log);

This returns:

[1, 2]
[2, 3]
[3, 4]
[4, 5]
[5]

I'd like for the result to look like (basically force the first value to emit):

[<userDefined>, 1]
[1, 2]
[3, 4]
etc...
Core
  • 840
  • 11
  • 24

1 Answers1

1

How about:

Rx.Observable.range(1, 5)
  // Note this value will get used for every subscription
  // after it is defined.
  .startWith(userDefined)
  .bufferWithCount(2, 1)
  .subscribe(console.log);
paulpdaniels
  • 18,395
  • 2
  • 51
  • 55
  • Of course. For some reason I didn't think to try startWith before bufferWithCount. Thanks. – Core Oct 18 '16 at 13:47