Reduce returns empty array, however scan does not
问题 Code: const Rx = require('rxjs') const data = [ { name: 'Zachary', age: 21 }, { name: 'John', age: 20 }, { name: 'Louise', age: 14 }, { name: 'Borg', age: 15 } ] const dataSubj$ = new Rx.Subject() function getDataStream() { return dataSubj$.asObservable().startWith(data); } getDataStream() .mergeMap(Rx.Observable.from) .scan((arr, person) => { arr.push(person) return arr }, []) .subscribe(val => console.log('val: ', val)); Using .reduce(...) instead of .scan(...) returns an empty array and