从一个数组的 observable 开始,然后将项目从一个 item observable 推送到它上面

Start with observable of an array and then push items on it from an item observable

我奇怪地坚持以下几点:

不确定我是否理解您的所有问题,但这里有一个建议:

const { Observable }  = Rx;

const startingArray$ = Observable.of([1, 2, 3]);

const additions$ = Observable.from([4, 5, 6, 7, 8]);

const startingArrayPlusAdditions$ = startingArray$
  .combineLatest(additions$)
  .scan((acc, current) => {
    const [startingArray, addition] = current;

    if (acc === null) {
      return [...startingArray, addition];
    } else {
      acc.push(addition);
      return acc;
    }
  }, null)
  .do(console.log)
  .subscribe();

输出为:

[1, 2, 3, 4]
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6, 7]
[1, 2, 3, 4, 5, 6, 7, 8]

正如你所问:

startingArrayPlusAdditions$ should emit every time additions$ emits, but it should not emit when startingArray$ emits initially

这是一个可用的 Plunkr:https://plnkr.co/edit/rKXLJrmA7mSzpQgoemlD?p=preview