1

Let say I have observables A, B, C. I have to listen to change of these three and alter a caculation.

i.e., On value change on any one of the obseravable, I need to recalculate with the new value from the present and the old value for the rest of the observables.

I tried to use combineLatest, which was perfect except the first behavior that all the observables should have a latest/change in the value.

4

1 回答 1

3

您可以在将每个源 ObservablestartWith传递给之前使用运算符为它们添加前缀combineLatest

combineLatest(
  obsA$.pipe(startWith(null)),
  obsB$.pipe(startWith(null)),
  obsC$.pipe(startWith(null)),
)

然后你必须手动检查什么是null.

于 2018-11-06T14:45:51.370 回答