vendredi 22 juillet 2016

RxJS groupBy and combineAll operators seem to omit output

When grouping output with the combination of .groupBy and .concatAll, some expected output is not generated.

Sample code:

var Rx = require('rx');

var source = Rx.Observable.from(['a1', 'a2', 'b1', 'b2', 'a3', 'a4', 'b3', 'b4'])
  .groupBy(function (item) { return item.substr(0, 1); })
  .concatAll();

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
    console.log('Completed');
  });

Actual output:

$ node index.js
Next: a1
Next: a2
Next: a3
Next: a4
Completed

Expected output:

$ node index.js
Next: a1
Next: a2
Next: a3
Next: a4
Next: b1
Next: b2
Next: b3
Next: b4
Completed

Am I misunderstanding how these operators work? Or is this an RxJS bug? (Tentatively filed as a bug already at https://github.com/Reactive-Extensions/RxJS/issues/1264.)

Aucun commentaire:

Enregistrer un commentaire